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`. diff --git a/Sortable.js b/Sortable.js index eef346791..5ccf4842f 100644 --- a/Sortable.js +++ b/Sortable.js @@ -533,6 +533,7 @@ dragoverBubble: false, dataIdAttr: 'data-id', delay: 0, + delayOnTouchOnly: 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.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