Skip to content

Commit 59ea482

Browse files
committed
removeOnSpill working on mobile closes bevacqua#98
1 parent 9931ba7 commit 59ea482

File tree

5 files changed

+33
-17
lines changed

5 files changed

+33
-17
lines changed

changelog.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Fixed a _historical_ bug, where click on anchors would be ignored within `dragula` containers in mobile
44
- Fixed a bug where events wouldn't be gracefully removed if `drake` were destroyed during a drag event
55
- Now emits `dragend` after `out` to preserve consistency _(because `drag` is emitted before `over`)_
6+
- Fixed another old bug where attempting to remove elements using `removeOnSpill` on mobile would fail
67

78
# 3.0.1 Carjacking
89

dragula.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ function dragula (initialContainers, options) {
4646
dragging: false
4747
});
4848

49+
if (o.removeOnSpill === true) {
50+
drake.on('over', spillOver).on('out', spillOut);
51+
}
52+
4953
events();
5054

5155
return drake;
@@ -338,7 +342,7 @@ function dragula (initialContainers, options) {
338342
reference = _initialSibling;
339343
dropTarget = _source;
340344
} else {
341-
if ((o.copy || o.removeOnSpill === true) && item.parentElement) {
345+
if (o.copy && item.parentElement) {
342346
item.parentElement.removeChild(item);
343347
}
344348
return;
@@ -358,6 +362,14 @@ function dragula (initialContainers, options) {
358362
function out () { if (_lastDropTarget) { moved('out'); } }
359363
}
360364

365+
function spillOver (el) {
366+
classes.rm(el, 'gu-hide');
367+
}
368+
369+
function spillOut (el) {
370+
if (drake.dragging) { classes.add(el, 'gu-hide'); }
371+
}
372+
361373
function renderMirrorImage () {
362374
if (_mirror) {
363375
return;

0 commit comments

Comments
 (0)