Browse Source

Adding the 'touchMoveSensitivity' option

pull/1205/head
Tai Poh Nean 7 years ago
parent
commit
3e2e94bd6b
  1. 15
      README.md
  2. 11
      Sortable.js
  3. 3
      Sortable.min.js

15
README.md

@ -82,6 +82,7 @@ var sortable = new Sortable(el, {
group: "name", // or { name: "...", pull: [true, false, clone], put: [true, false, array] }
sort: true, // sorting inside list
delay: 0, // time in milliseconds to define when the sorting should start
touchMoveSensitivity: 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
animation: 150, // ms, animation speed moving items when sorting, `0` — without animation
@ -213,6 +214,20 @@ Demo: http://jsbin.com/xizeh/edit?html,js,output
---
#### `touchMoveSensitivity` option
This option is similar to `fallbackTolerance` option.
When the `delay` option is set, some phones with very sensitive touch displays like the Samsung Galaxy S8 will fire
unwanted touchmove events even when your finger is not moving, resulting in the sort not triggering.
This option sets the minimum pointer movement that must occur before the delayed sorting is cancelled.
Values between 3 to 5 are good.
---
#### `disabled` options
Disables the sortable if set to `true`.

11
Sortable.js

@ -271,6 +271,7 @@
dragoverBubble: false,
dataIdAttr: 'data-id',
delay: 0,
touchMoveSensitivity: 0,
forceFallback: false,
fallbackClass: 'sortable-fallback',
fallbackOnBody: false,
@ -452,8 +453,8 @@
_on(ownerDocument, 'touchend', _this._disableDelayedDrag);
_on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
_on(ownerDocument, 'mousemove', _this._disableDelayedDrag);
_on(ownerDocument, 'touchmove', _this._disableDelayedDrag);
options.supportPointer && _on(ownerDocument, 'pointermove', _this._disableDelayedDrag);
_on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
options.supportPointer && _on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
_this._dragStartTimer = setTimeout(dragStartFn, options.delay);
} else {
@ -464,6 +465,12 @@
}
},
_delayedDragTouchMoveHandler: function (/** TouchEvent|PointerEvent **/e) {
if (min(abs(e.clientX - this._lastX), abs(e.clientY - this._lastY)) > this.options.touchMoveSensitivity) {
this._disableDelayedDrag();
}
},
_disableDelayedDrag: function () {
var ownerDocument = this.el.ownerDocument;

3
Sortable.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save