Skip to content

Commit

Permalink
Only handle nearestEmptyInsertDetectEvent while dragEl is set
Browse files Browse the repository at this point in the history
Since the callback doesn't do anything otherwise anyway
  • Loading branch information
lehni committed Apr 4, 2019
1 parent 75a4882 commit 2d638da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions Sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@
}, true);

var nearestEmptyInsertDetectEvent = function(evt) {
evt = evt.touches ? evt.touches[0] : evt;
if (dragEl) {
evt = evt.touches ? evt.touches[0] : evt;
var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);

if (nearest) {
Expand All @@ -477,10 +477,6 @@
}
}
};
// We do not want this to be triggered if completed (bubbling canceled), so only define it here
_on(document, 'dragover', nearestEmptyInsertDetectEvent);
_on(document, 'mousemove', nearestEmptyInsertDetectEvent);
_on(document, 'touchmove', nearestEmptyInsertDetectEvent);

/**
* @class Sortable
Expand Down Expand Up @@ -805,6 +801,10 @@
_find(dragEl, criteria.trim(), _disableDraggable);
});

// We do not want this to be triggered if completed (bubbling canceled), so only define it here
_on(document, 'dragover', nearestEmptyInsertDetectEvent);
_on(document, 'mousemove', nearestEmptyInsertDetectEvent);
_on(document, 'touchmove', nearestEmptyInsertDetectEvent);
if (options.supportPointer) {
_on(ownerDocument, 'pointerup', _this._onDrop);
} else {
Expand Down Expand Up @@ -1412,6 +1412,12 @@
}
},

_offMoveEvents: function() {
_off(document, 'dragover', nearestEmptyInsertDetectEvent);
_off(document, 'mousemove', nearestEmptyInsertDetectEvent);
_off(document, 'touchmove', nearestEmptyInsertDetectEvent);
},

_offUpEvents: function () {
var ownerDocument = this.el.ownerDocument;

Expand Down Expand Up @@ -1458,6 +1464,7 @@
_css(document.body, 'user-select', '');
}

this._offMoveEvents();
this._offUpEvents();

if (evt) {
Expand Down
Loading

0 comments on commit 2d638da

Please sign in to comment.