Right now there seems to be no way to cancel dragging an element. If the user started to drag an item and changed their mind, they have to remember where the element started from, and drag it back there. Esc just drops the element, as does releasing the mouse button.
Would it be more useful if Esc aborted the drag operation and animated the element back in its original place?
Have to think, it sounds reasonable.
Kendo UI Core Sortable has a nice implementation of this feature.
https://github.com/RubaXa/Sortable/blob/master/Sortable.js#L514 needs to be modified like this:
else if (dragEl.nextSibling !== nextEl && evt.dataTransfer.dropEffect !== 'none') {
// Update event if element was dragged, and Esc was not pressed
...undo drag code here?...
evt.dataTransfer === undefinedWell yes, on a touch device you can't press Esc. What would be the code to move the element back? Seems like onStart should store the start position (prevSibling || nextSibling), then onEnd would move the element to that stored start position, after prevSibling (unless it was the first element) or before nextSibling otherwise.
Well yes, on a touch device you can't press Esc. What would be the code to move the element back? Seems like onStart should store the start position (prevSibling || nextSibling), then onEnd would move the element to that stored start position, after prevSibling (unless it was the first element) or before nextSibling otherwise.
Looking forward for this. Any ETA @owen-m1 ?