How can I set so that only .btn-drag
can drag whole row? I am using https://github.com/SortableJS/Vue.Draggable
Currently I can drag also with button#options
which is undesired
<draggable v-model="textElements">
<transition-group>
<div class="is-draggable" v-for="element in textElements" :key="element.text">
<div>
{{ element.text }}
</div>
<button class="btn btn-transparent">Options</button>
<button class="btn btn-transparent btn-drag">Drag</button>
</div>
</transition-group>
</draggable>
In docs they mention that we can place :move="checkMove"
on <draggable>
but in function I am not sure how can I check what exactly was dragged? Returning false works correctly for disabling dragging in general
methods: {
checkMove(evt) {
console.log(evt)
return false
}
}
Console.log(evt) shows this but I am not sure which property I can use to pinpoint exactly what started a drag https://image.prntscr.com/image/r17zNkxoSWGdVQs_5nR09w.png
Starting from version 2.19, you can use
<draggable handle=".handle">
The functionality is called "handles".
https://github.com/SortableJS/Vue.Draggable#features
https://github.com/SortableJS/Vue.Draggable#options
https://github.com/RubaXa/Sortable#optionshandle
option here should help.
Here the elements with class "item" are only draggable , that can specified like this draggable=".item" usign the draggable option inside the draggable tag
<draggable v-model="myArray" draggable=".item">
<div v-for="element in myArray" :key="element.id" class="item">
{{element.name}}
</div>
<button slot="header" @click="addPeople">Add</button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With