phphe / vue-draggable-nested-tree

Vue2 draggable tree component
https://hetree.phphe.com/
MIT License
345 stars 62 forks source link

Is it possible to clone an item on drag? [supported in new repo: he-tree-vue] #25

Closed hybridwebdev closed 4 years ago

hybridwebdev commented 6 years ago

Sorry, I checked the examples, and can't see any parameter that allows for an element to be cloned on drag. Is this a possibility?

phphe commented 6 years ago

no, it doesn't support this case.

FlameArtLab commented 6 years ago

I got it.

Firstly, you need fix the https://github.com/phphe/vue-draggable-nested-tree/issues/38

Then add information about target in drop event (DraggableTreeNode.vue), appendTo and targetTree:

      drop: (e, opt, store) => {
        const draggableHelperInfo = {
          event: e, options: opt, store,
          appendTo: dplh._vm.$parent.data,
          targetTree: dplh._vm.store
        }

And just hook ondragend in your code, return false and push pure copy of element into target:

  ondragend(node, draggableHelperInfo) {

    if(!draggableHelperInfo.appendTo.hasOwnProperty('children')) 
      draggableHelperInfo.appendTo['children']=[];

    draggableHelperInfo.appendTo.children.push(draggableHelperInfo.targetTree.pure(node, true));

    return false;
  }

i realize that in https://github.com/FlameArtLab/vue-draggable-nested-tree/commit/a11ff522ba008d3c0bc6dd954e144635f3859a8d

This solution visually worse, than clone in Nested Sortable for jquery, and it only append, but it worked good and you can use insertAfter\Before in ur code for precise positioning

phphe commented 5 years ago

I think ondragstart is better for clone. The feature will make it more complex. I may add it in the future.

BackMoonTheWall commented 5 years ago

so now in version 2.2.17 ,how can i clone node and drag?

phphe commented 5 years ago

still not support

phphe commented 5 years ago

so now in version 2.2.17 ,how can i clone node and drag?

still not support

Kamyhin commented 4 years ago

Hi! still not support?

phphe commented 4 years ago

This is supported in new repo: he-tree-vue https://he-tree-vue.phphe.com/api.html#clonewhendrag vue-draggable-nested-tree don't support this, and it is no longer be maintained

Kamyhin commented 4 years ago

Well thank you!