From 20543ac6d66e7d01f273264671ea8fc6c73d0b55 Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 20 May 2024 17:57:32 +0800 Subject: [PATCH 1/3] Fix touch event listener: NONE warning --- src/Sortable.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Sortable.js b/src/Sortable.js index 81ff84494..914b5e32e 100644 --- a/src/Sortable.js +++ b/src/Sortable.js @@ -691,6 +691,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ { if (!this.nativeDraggable || touch) { if (this.options.supportPointer) { on(document, 'pointermove', this._onTouchMove); + on(document, 'touchmove', this._preventTouchMove); } else if (touch) { on(document, 'touchmove', this._onTouchMove); } else { @@ -849,6 +850,12 @@ Sortable.prototype = /** @lends Sortable.prototype */ { } }, + _preventTouchMove: function (/**TouchEvent*/evt) { + if (evt.cancelable) { + evt.preventDefault(); + } + }, + _appendGhost: function () { // Bug if using scale(): https://stackoverflow.com/questions/2637058 // Not being adjusted for @@ -1322,6 +1329,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ { off(document, 'mousemove', this._onTouchMove); off(document, 'touchmove', this._onTouchMove); off(document, 'pointermove', this._onTouchMove); + off(document, 'touchmove', this._preventTouchMove); off(document, 'dragover', nearestEmptyInsertDetectEvent); off(document, 'mousemove', nearestEmptyInsertDetectEvent); off(document, 'touchmove', nearestEmptyInsertDetectEvent); @@ -1933,16 +1941,6 @@ function _cancelNextTick(id) { return clearTimeout(id); } -// Fixed #973: -if (documentExists) { - on(document, 'touchmove', function(evt) { - if ((Sortable.active || awaitingDragStarted) && evt.cancelable) { - evt.preventDefault(); - } - }); -} - - // Export utils Sortable.utils = { on, From b1ba82be279ec7cb70d4f2aa1671e9f31b679969 Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 20 May 2024 18:01:35 +0800 Subject: [PATCH 2/3] Always apply _preventTouchMove --- src/Sortable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sortable.js b/src/Sortable.js index 914b5e32e..73df6e554 100644 --- a/src/Sortable.js +++ b/src/Sortable.js @@ -691,12 +691,12 @@ Sortable.prototype = /** @lends Sortable.prototype */ { if (!this.nativeDraggable || touch) { if (this.options.supportPointer) { on(document, 'pointermove', this._onTouchMove); - on(document, 'touchmove', this._preventTouchMove); } else if (touch) { on(document, 'touchmove', this._onTouchMove); } else { on(document, 'mousemove', this._onTouchMove); } + on(document, 'touchmove', this._preventTouchMove); } else { on(dragEl, 'dragend', this); on(rootEl, 'dragstart', this._onDragStart); From cbf67289a2f8ec5f5eb8d76eeed6f45ae654b84d Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 20 May 2024 19:27:03 +0800 Subject: [PATCH 3/3] Keep the old one on FireFox and Safari --- src/Sortable.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Sortable.js b/src/Sortable.js index 73df6e554..21386b10e 100644 --- a/src/Sortable.js +++ b/src/Sortable.js @@ -1941,6 +1941,15 @@ function _cancelNextTick(id) { return clearTimeout(id); } +// Fixed #973: +if (documentExists && (FireFox || Safari)) { + on(document, 'touchmove', function(evt) { + if ((Sortable.active || awaitingDragStarted) && evt.cancelable) { + evt.preventDefault(); + } + }); +} + // Export utils Sortable.utils = { on,