Alfred-Skyblue / vue-draggable-plus

Universal Drag-and-Drop Component Supporting both Vue 3 and Vue 2
https://vue-draggable-plus.pages.dev/en/
MIT License
2.74k stars 106 forks source link

Is it possible to validate whether or not you can drag? #32

Closed luisrossi closed 11 months ago

luisrossi commented 11 months ago

Is there a way for me to validate in a method whether or not an element can be dragged to another parent component? In summary my use case is: I have 2 lists and some specific list items can be dragged to another list and some not

Example:

if (event.clone.className === "fixed" && event.to.id === "availableFields") {

would be equivalent to prop :move="function" of vuedraggable

Alfred-Skyblue commented 11 months ago

onMove or @move return false.

 <VueDraggable
      v-model="list1"
      :onMove="(e) => false"
    >
 </VueDraggable>

or

 <VueDraggable
      v-model="list1"
      @move="(e) => false"
    >
 </VueDraggable>
luisrossi commented 11 months ago

Move within the component itself for sorting. That yes, today is already validated. But when it's from one component to the other, the move is not activated, but the remove/add and I can't cancel it.

I had to do the treatment by hand.