From 7e1d7893cb2e354aa28af0f19e45ccab7ac554c0 Mon Sep 17 00:00:00 2001 From: Sean O'Grady Date: Thu, 4 Apr 2019 12:32:00 +0100 Subject: [PATCH 1/3] Add option to only apply delay on touch events --- Sortable.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sortable.js b/Sortable.js index eef346791..a350384ae 100644 --- a/Sortable.js +++ b/Sortable.js @@ -533,6 +533,7 @@ dragoverBubble: false, dataIdAttr: 'data-id', delay: 0, + delayOnTouch: false, touchStartThreshold: parseInt(window.devicePixelRatio, 10) || 1, forceFallback: false, fallbackClass: 'sortable-fallback', @@ -820,7 +821,7 @@ } // Delay is impossible for native DnD in Edge or IE - if (options.delay && (!this.nativeDraggable || !(Edge || IE11OrLess))) { + if (options.delay && (options.delayOnTouch && touch !== undefined) && (!this.nativeDraggable || !(Edge || IE11OrLess))) { // If the user moves the pointer or let go the click or touch // before the delay has been reached: // disable the delayed drag From 9ae3dac7d8848f5a9fa9e9091e67a299a3c6502b Mon Sep 17 00:00:00 2001 From: owen-m1 Date: Fri, 19 Apr 2019 08:56:45 -0400 Subject: [PATCH 2/3] Renamed option + fixed boolean logic --- Sortable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sortable.js b/Sortable.js index a350384ae..5ccf4842f 100644 --- a/Sortable.js +++ b/Sortable.js @@ -533,7 +533,7 @@ dragoverBubble: false, dataIdAttr: 'data-id', delay: 0, - delayOnTouch: false, + delayOnTouchOnly: false, touchStartThreshold: parseInt(window.devicePixelRatio, 10) || 1, forceFallback: false, fallbackClass: 'sortable-fallback', @@ -821,7 +821,7 @@ } // Delay is impossible for native DnD in Edge or IE - if (options.delay && (options.delayOnTouch && touch !== undefined) && (!this.nativeDraggable || !(Edge || IE11OrLess))) { + if (options.delay && (options.delayOnTouchOnly ? touch : true) && (!this.nativeDraggable || !(Edge || IE11OrLess))) { // If the user moves the pointer or let go the click or touch // before the delay has been reached: // disable the delayed drag From 41549cf8c2433edf0f36c78e62eb647b4f713bfb Mon Sep 17 00:00:00 2001 From: owen-m1 Date: Fri, 19 Apr 2019 20:38:23 -0400 Subject: [PATCH 3/3] documentation --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 201f94222..769adc908 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ var sortable = new Sortable(el, { group: "name", // or { name: "...", pull: [true, false, 'clone', array], put: [true, false, array] } sort: true, // sorting inside list delay: 0, // time in milliseconds to define when the sorting should start + delayOnTouchOnly: false, // only delay if user is using touch touchStartThreshold: 0, // px, how many pixels the point should move before cancelling a delayed drag event disabled: false, // Disables the sortable if set to true. store: null, // @see Store @@ -245,6 +246,13 @@ Demo: https://jsbin.com/zosiwah/edit?js,output --- +#### `delayOnTouchOnly` option +Whether or not the delay should be applied only if the user is using touch (eg. on a mobile device). No delay will be applied in any other case. Defaults to `false`. + + +--- + + #### `swapThreshold` option Percentage of the target that the swap zone will take up, as a float between `0` and `1`.