simple drag and drop component
$ component install ecarter/dragdrop
- dead simple drag and drop event handling
- auto-binds to all
draggable="true"
children elements - adds
dragging
andover
classes for element styling - no jquery dependency 👍
start
(el) on drag startenter
(el) when drag entersdraggable
targetover
(el) when drag is over targetleave
(el) when drag leaves targetend
(el) when drag event endsdrop
(drag, drop) when drag to drop completes
Drag a element and replace it with another:
var draggable = Dragdrop(el);
draggable.on('drop', function(drag, drop){
var dragged = drag.cloneNode(true);
var dropped = drop.cloneNode(true);
list.replaceChild(dragged, drop);
list.replaceChild(dropped, drag);
console.log('dropped element', drag, 'to element', drop);
});
MIT