timeline-plus
timeline-plus copied to clipboard
Improve drag&drop
Hi @yotamberk and thanks for having forked this Timeline module from Vis ! 😄
I want to improve timeline-plus
by adding the ability to "snap" non-timeline-item to the timeline when dragging.
In other words, I want to :
- add a "temporary item" when
dragEnter
in the timeline - move it on the timeline like a real one
- set it as a real one if I drop it on the timeline OR remove it if I drop it outside.
I found in the code a beggining of implementation https://github.com/yotamberk/timeline-plus/blob/master/lib/timeline/Core.js#L302 (I think). Can you give me hints to develop this feature ? (and make a PR to improve the lib of course 😄 )
Hey Yotam, Do you have some tips for this one ?
Cheers 😄
I would start with hooking new behavior to the 'mousedown' event on the ItemSet
component and check if you have data on the drag handler, and make sure that as long as the mousedown is still on, that an item is still selected and moved on the timeline while mousemove is triggered.
I think the temporary item should be added as a regular item with different CSS and is changed to a normal item only once the 'drop' event is triggered.
Does this help?
Your comment helps me a lot! I'll try to implement that, this week. I keep you up to date.