Sortable: Esc to abort drag?

Created on 1 Dec 2014  路  7Comments  路  Source: SortableJS/Sortable

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?

enhancement

All 7 comments

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?...
  1. The element is already moved.
  2. If it is a touch-device: evt.dataTransfer === undefined

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.

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 ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seltix5 picture seltix5  路  3Comments

binitghetiya picture binitghetiya  路  4Comments

geonanorch picture geonanorch  路  3Comments

pageYe123 picture pageYe123  路  3Comments

Webifi picture Webifi  路  3Comments