Skip to content

Commit 2d638da

Browse files
committed
Only handle nearestEmptyInsertDetectEvent while dragEl is set
Since the callback doesn't do anything otherwise anyway
1 parent 75a4882 commit 2d638da

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Sortable.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@
460460
}, true);
461461

462462
var nearestEmptyInsertDetectEvent = function(evt) {
463-
evt = evt.touches ? evt.touches[0] : evt;
464463
if (dragEl) {
464+
evt = evt.touches ? evt.touches[0] : evt;
465465
var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
466466

467467
if (nearest) {
@@ -477,10 +477,6 @@
477477
}
478478
}
479479
};
480-
// We do not want this to be triggered if completed (bubbling canceled), so only define it here
481-
_on(document, 'dragover', nearestEmptyInsertDetectEvent);
482-
_on(document, 'mousemove', nearestEmptyInsertDetectEvent);
483-
_on(document, 'touchmove', nearestEmptyInsertDetectEvent);
484480

485481
/**
486482
* @class Sortable
@@ -805,6 +801,10 @@
805801
_find(dragEl, criteria.trim(), _disableDraggable);
806802
});
807803

804+
// We do not want this to be triggered if completed (bubbling canceled), so only define it here
805+
_on(document, 'dragover', nearestEmptyInsertDetectEvent);
806+
_on(document, 'mousemove', nearestEmptyInsertDetectEvent);
807+
_on(document, 'touchmove', nearestEmptyInsertDetectEvent);
808808
if (options.supportPointer) {
809809
_on(ownerDocument, 'pointerup', _this._onDrop);
810810
} else {
@@ -1412,6 +1412,12 @@
14121412
}
14131413
},
14141414

1415+
_offMoveEvents: function() {
1416+
_off(document, 'dragover', nearestEmptyInsertDetectEvent);
1417+
_off(document, 'mousemove', nearestEmptyInsertDetectEvent);
1418+
_off(document, 'touchmove', nearestEmptyInsertDetectEvent);
1419+
},
1420+
14151421
_offUpEvents: function () {
14161422
var ownerDocument = this.el.ownerDocument;
14171423

@@ -1458,6 +1464,7 @@
14581464
_css(document.body, 'user-select', '');
14591465
}
14601466

1467+
this._offMoveEvents();
14611468
this._offUpEvents();
14621469

14631470
if (evt) {

0 commit comments

Comments
 (0)