I am trying to create draggable object in Vuejs from scratch. But I am facing 2 problem right now.
- When DragEnd , the object just snap to the target coordinate instantly.
- I've tried to remove the 'Ghosting image' by setting opacity to 0% when drag, but that doesn't seemed to work.
here is the code i am working on right now. 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;
}