I'm having hard times sorting elements within the tree, especially correlating to my problem with performance of the drop zones showing up with a high latency described in issue #173.
I do have ideas on how to make sorting nodes within the same level easier, however have no idea on how to get started with this? And which way is the most promising one? Can anyone give me an hint?
Is it anyhow possible to adjust the drop zone sizes to make it easer to drop an node between to nodes of same size?
Can the drop zones between two nodes be extended to overlap the nodes?
Is it possible to "magnetically" jump to the next closest droppable drop-zone between to posts even though the course is not exactly over it? (eg. using allowDrop allows to only drop between nodes but not onto child nodes, thus the next magnetic drop zone would be befor or after the node the courser is currently on?
Increase the drop zones close the the items there the mouse is dragging an node over is close to. Eg. increase the drop zones before and after the item there the mouse is currently dragging over.
I'm thinking of a similar behavior like dragula has it for sorting list, just for the tree.
Background
I'm trying to sort elements within a tree. My nodes do have a fixed level according to their type. eg. root-category and sub-category. I'm using a simple allowDrop function to only allow to drop the sub-category onto any root-category or between two other sub-categories.
allowDrop: (d, t) => {
return (
( d.data.type=="sub" && t.parent.level==1 ) ||聽
( d.data.type=="root" && t.parent.level==0 )
);
}
Maybe this is a try with css. The idea is to increase the node-drop-slot like the mac os bottom menu bar. Then you hover an element the closest elements increase.
My first try was with a css hover effect. However :hover is not applied then an element is dragged :/ also it only works for going down with mouse, since there is no css selector for before.
treenode:hover > div > treenodedropslot > div.node-drop-slot {
background: red;
min-height: 20px;
}
Thus I increased the drop zone with a negative margin over the nodes them selves. However this solutions is still a little bit flickery.
.node-drop-slot {
position: relative;
/*background: red;*/
/* padding: 8px 0;*/
height: 12px !important;
margin: -6px 0;
z-index: 1000;
}
.node-drop-slot.is-dragging-over {
/*height:30px !important;*/
margin:0;
height: 24px !important;
/*background-color: blue !important;*/
}
Maybe it makes sense to add the .is-dragging-over also to the .tree-node-leaf or even better an class .is-tragging-over-next to the previous tree-node-leaf? This would allow to increase the space ahead of the mouse coming close. Using css3 transitions would allow to make the increase smooth.
what you guys think?
Hey @manuelfink
I agree the dropzones need to be improved. We'll look into the suggestions you've made.
Also using dragula might help with #65
If you feel like doing a pull request it would be greatly appreciated
I stumbled over dragula my self looking for drag and drop solutions. Considering switching to dragula I would put this issue back till dragula is integrated since it seems to me that they are doing pretty much this plus a lot more optimizations.
My shared css is little away from being optimizes for good usability since it makes clicking and dragging nodes harder thus I think this needs some tweaking ahead of a pull request
It has a wrapper for Angular2 here: https://github.com/valor-software/ng2-dragula
I just started to learn angular2. This tree module looks really promising!
Yes I've looked into it, in this case looks like using the original dragula is better.
This is definitely one of the top priorities for this component.
Hi,
Are there any updates on this request?
@adrian-mitangi I'm looking into refactoring the DnD, but it's quite a big task so I can't give a specific deadline yet
Would there be any updates on making dropping easier? I've got the component set up to where only certain nodes can be dropped on. Therefore, majority of nodes have a huge drop target (the nodes themselves) that are unusable.
Would like to configure drop target to only be between the nodes themselves unless they are "allowDrop"-able.
Most helpful comment
@adrian-mitangi I'm looking into refactoring the DnD, but it's quite a big task so I can't give a specific deadline yet