Browse Source

Merge pull request #1205 from pohnean/master

Adding the 'touchMoveSensitivity' option
swap
Lebedev Konstantin 7 years ago committed by GitHub
parent
commit
d8b46ee394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      README.md
  2. 11
      Sortable.js
  3. 2
      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

@ -282,6 +282,7 @@
dragoverBubble: false,
dataIdAttr: 'data-id',
delay: 0,
touchMoveSensitivity: 0,
forceFallback: false,
fallbackClass: 'sortable-fallback',
fallbackOnBody: false,
@ -463,8 +464,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 {
@ -475,6 +476,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;

2
Sortable.min.js vendored

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