diff --git a/README.md b/README.md index c46a5257f..cddfb4ba8 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 @@ -247,6 +248,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`. diff --git a/Sortable.js b/Sortable.js index 455b95159..d5c5d6185 100644 --- a/Sortable.js +++ b/Sortable.js @@ -529,6 +529,7 @@ dragoverBubble: false, dataIdAttr: 'data-id', delay: 0, + delayOnTouchOnly: false, touchStartThreshold: parseInt(window.devicePixelRatio, 10) || 1, forceFallback: false, fallbackClass: 'sortable-fallback', @@ -819,7 +820,7 @@ } // Delay is impossible for native DnD in Edge or IE - if (options.delay && (!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