Skip to content

Nested list (tree) - how to nest elements by dragging to the right? #1709

Open
@ddenev

Description

@ddenev

I am using the Vue.Draggable binding for SortableJS to build a draggable tree structure.

I built the tree and DnD works just fine. Now I want to implement nesting a node by dragging it horizontally to the right, under the node that I want to nest it into.

Here is my question about that on Stackoverflow (the Vue.Draggable dev requires such questions to be asked on Stackoverflow but I still haven't received any answer there). So I ask here since I believe that if that feature would be supported by SortableJS then it would also work in Vue.Draggable.

What would be the approach with Vue.Draggable/SortableJS in order to achieve the functionality as shown in this animated gif?
H7U5D

The default behavior of Sortable for nesting is to drag the element up to the above element until the mouse reaches emptyInsertThreshold pixels from the drop zone of the above element but I would like to be able to nest elements by dragging them to the right. Same for un-nesting.

I have set emptyInsertThreshold to 0 to disable the default behavior and now when I drag the element to the right I get the following events fired: clone and start (in that order).

But how do I:

  1. Can get notified when the mouse has traveled the pre-defined distance to the right?
  2. Inform Vue.Draggable that the ghost element should be nested as a child to the element under which I am doing the horizontal movement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions