Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
copy bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bevacqua committed Jun 30, 2015
1 parent 9a53022 commit 152bf5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions changelog.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.0.1 Copycat

- Fixed a bug where dragging a copy back to origin after hovering over another container would still result in a copy being made if you never spilled the item

# 2.0.0 Containerization

- Deprecated `addContainer` method
Expand Down
15 changes: 9 additions & 6 deletions dragula.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function dragula (initialContainers, options) {
if (o.accepts === void 0) { o.accepts = always; }
if (o.invalid === void 0) { o.invalid = invalidTarget; }
if (o.containers === void 0) { o.containers = initialContainers || []; }
if (o.isContainer === void 0) { o.isContainer = falseop; }
if (o.isContainer === void 0) { o.isContainer = never; }
if (o.copy === void 0) { o.copy = false; }
if (o.revertOnSpill === void 0) { o.revertOnSpill = false; }
if (o.removeOnSpill === void 0) { o.removeOnSpill = false; }
Expand Down Expand Up @@ -70,10 +70,6 @@ function dragula (initialContainers, options) {
return api.containers.indexOf(el) !== -1 || o.isContainer(el);
}

function falseop () {
return false;
}

function events (remove) {
var op = remove ? 'remove' : 'add';
touchy(documentElement, op, 'mousedown', grab);
Expand Down Expand Up @@ -299,13 +295,16 @@ function dragula (initialContainers, options) {
_mirror.style.left = x + 'px';
_mirror.style.top = y + 'px';

var item = _copy || _item;
var elementBehindCursor = getElementBehindPoint(_mirror, _clientX, _clientY);
var dropTarget = findDropTarget(elementBehindCursor, _clientX, _clientY);
if (dropTarget === _source && o.copy) {
if (item.parentElement) {
item.parentElement.removeChild(item);
}
return;
}
var reference;
var item = _copy || _item;
var immediate = getImmediateChild(dropTarget, elementBehindCursor);
if (immediate !== null) {
reference = getReference(dropTarget, immediate, _clientX, _clientY);
Expand Down Expand Up @@ -445,6 +444,10 @@ function getElementBehindPoint (point, x, y) {
return el;
}

function never () {
return false;
}

function always () {
return true;
}
Expand Down

0 comments on commit 152bf5a

Please sign in to comment.