【发布时间】:2020-03-20 03:19:23
【问题描述】:
我正在尝试从头开始在 Vuejs 中创建可拖动对象。 但我现在面临两个问题。
- 当 DragEnd 时,对象只是捕捉到目标坐标 即刻。
- 我尝试通过设置删除“重影图像” 拖动时不透明度为 0%,但这似乎不起作用。
这是我现在正在处理的代码。 https://jsfiddle.net/wmsk1npb/
<div id="app">
{{x}}/{{y}} ....... {{coordinates}}
<div class="bubbleMenuContainer" :style="coordinates" draggable="true" @drag="move" @dragend="set">
Test
</div>
</div>
new Vue({
el: '#app',
data: {
x:0,
y:0,
coordinates:{
top: "100px",
left: "100px",
opacity: "100%",
}
},
methods:{
move(event){
this.x = event.clientX;
this.y = event.clientY;
this.coordinates.left = event.clientX + "px";
this.coordinates.top = event.clientY + "px";
this.coordinates.opacity = "0%;"
},
set(event){
this.coordinates.left = event.clientX + "px";
this.coordinates.top = event.clientY + "px";
this.coordinates.opacity = "100%;"
}
}
})
.bubbleMenuContainer{
position: absolute;
border-radius: 100px;
background-color: lightcoral;
width: 30px;
height: 30px;
padding: 10px;
}
【问题讨论】:
标签: javascript vue.js draggable drag