Vue Dragenter and Leave
by Manuel E
HTML
<div id="app">
<div class="draggable" draggable> Drag me </div>
<div class="drop-zone" @dragenter="onDragEnter" @dragleave="onDragleave">
<div class="child1"> </div>
<div class="child2"> </div>
</div>
<div>
{{enterAndLeave}}
</div>
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
.child1 {
height: 50px;
width: 100px;
background-color: red;
}
.child2 {
height: 50px;
width: 100px;
background-color: blue;
}
.draggable {
height: 50px;
width: 50px;
background-color: black;
color: white;
}
Vue
new Vue({
el: "#app",
data: {
enterAndLeave: ""
},
methods: {
onDragEnter: function(){
this.enterAndLeave += " ENTER"
},
onDragleave: function(){
this.enterAndLeave += " LEAVE"
}
}
})