Browse Source

#590: * fallbackTolerance

pull/650/head
RubaXa 9 years ago
parent
commit
d359188d65
  1. 22
      Sortable.js

22
Sortable.js

@ -68,6 +68,7 @@
_silent = false, _silent = false,
abs = Math.abs, abs = Math.abs,
min = Math.min,
slice = [].slice, slice = [].slice,
touchDragOverListeners = [], touchDragOverListeners = [],
@ -469,26 +470,27 @@
_onTouchMove: function (/**TouchEvent*/evt) { _onTouchMove: function (/**TouchEvent*/evt) {
if (tapEvt) { if (tapEvt) {
var options = this.options,
var touch = evt.touches ? evt.touches[0] : evt; fallbackTolerance = options.fallbackTolerance,
touch = evt.touches ? evt.touches[0] : evt,
dx = touch.clientX - tapEvt.clientX,
dy = touch.clientY - tapEvt.clientY,
translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)';
// only set the status to dragging, when we are actually dragging // only set the status to dragging, when we are actually dragging
if (!Sortable.active) { if (!Sortable.active) {
if (this.options.fallbackTolerance) { if (fallbackTolerance &&
if (Math.min(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < this.options.fallbackTolerance) { min(abs(touch.clientX - this._lastX), abs(touch.clientY - this._lastY)) < fallbackTolerance
return; ) {
} return;
} }
this._dragStarted(); this._dragStarted();
} }
// as well as creating the ghost element on the document body // as well as creating the ghost element on the document body
this._appendGhost(); this._appendGhost();
var dx = touch.clientX - tapEvt.clientX,
dy = touch.clientY - tapEvt.clientY,
translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)';
moved = true; moved = true;
touchEvt = touch; touchEvt = touch;

Loading…
Cancel
Save