Browse Source

+ master & #913

pull/995/head
RubaXa 8 years ago
parent
commit
2a33f3bc4a
  1. 14
      Sortable.js

14
Sortable.js

@ -284,6 +284,7 @@
// Bind events // Bind events
_on(el, 'mousedown', this._onTapStart); _on(el, 'mousedown', this._onTapStart);
_on(el, 'touchstart', this._onTapStart); _on(el, 'touchstart', this._onTapStart);
_on(el, 'pointerdown', this._onTapStart);
if (this.nativeDraggable) { if (this.nativeDraggable) {
_on(el, 'dragover', this); _on(el, 'dragover', this);
@ -395,7 +396,7 @@
_toggleClass(dragEl, options.chosenClass, true); _toggleClass(dragEl, options.chosenClass, true);
// Bind the events: dragstart/dragend // Bind the events: dragstart/dragend
_this._triggerDragStart(touch); _this._triggerDragStart(evt, touch);
// Drag start event // Drag start event
_dispatchEvent(_this, rootEl, 'choose', dragEl, rootEl, oldIndex); _dispatchEvent(_this, rootEl, 'choose', dragEl, rootEl, oldIndex);
@ -409,6 +410,7 @@
_on(ownerDocument, 'mouseup', _this._onDrop); _on(ownerDocument, 'mouseup', _this._onDrop);
_on(ownerDocument, 'touchend', _this._onDrop); _on(ownerDocument, 'touchend', _this._onDrop);
_on(ownerDocument, 'touchcancel', _this._onDrop); _on(ownerDocument, 'touchcancel', _this._onDrop);
_on(ownerDocument, 'pointercancel', _this._onDrop);
if (options.delay) { if (options.delay) {
// If the user moves the pointer or let go the click or touch // If the user moves the pointer or let go the click or touch
@ -419,6 +421,7 @@
_on(ownerDocument, 'touchcancel', _this._disableDelayedDrag); _on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
_on(ownerDocument, 'mousemove', _this._disableDelayedDrag); _on(ownerDocument, 'mousemove', _this._disableDelayedDrag);
_on(ownerDocument, 'touchmove', _this._disableDelayedDrag); _on(ownerDocument, 'touchmove', _this._disableDelayedDrag);
_on(ownerDocument, 'pointermove', _this._disableDelayedDrag);
_this._dragStartTimer = setTimeout(dragStartFn, options.delay); _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
} else { } else {
@ -436,9 +439,11 @@
_off(ownerDocument, 'touchcancel', this._disableDelayedDrag); _off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
_off(ownerDocument, 'mousemove', this._disableDelayedDrag); _off(ownerDocument, 'mousemove', this._disableDelayedDrag);
_off(ownerDocument, 'touchmove', this._disableDelayedDrag); _off(ownerDocument, 'touchmove', this._disableDelayedDrag);
_off(ownerDocument, 'pointermove', this._disableDelayedDrag);
}, },
_triggerDragStart: function (/** Touch */touch) { _triggerDragStart: function (/** Event */evt, /** Touch */touch) {
touch = touch || (evt.pointerType == 'touch' ? evt : null);
if (touch) { if (touch) {
// Touch device support // Touch device support
tapEvt = { tapEvt = {
@ -618,6 +623,8 @@
_on(document, 'touchmove', this._onTouchMove); _on(document, 'touchmove', this._onTouchMove);
_on(document, 'touchend', this._onDrop); _on(document, 'touchend', this._onDrop);
_on(document, 'touchcancel', this._onDrop); _on(document, 'touchcancel', this._onDrop);
_on(document, 'pointermove', this._onTouchMove);
_on(document, 'pointerup', this._onDrop);
} else { } else {
// Old brwoser // Old brwoser
_on(document, 'mousemove', this._onTouchMove); _on(document, 'mousemove', this._onTouchMove);
@ -808,8 +815,10 @@
var ownerDocument = this.el.ownerDocument; var ownerDocument = this.el.ownerDocument;
_off(document, 'touchmove', this._onTouchMove); _off(document, 'touchmove', this._onTouchMove);
_off(document, 'pointermove', this._onTouchMove);
_off(ownerDocument, 'mouseup', this._onDrop); _off(ownerDocument, 'mouseup', this._onDrop);
_off(ownerDocument, 'touchend', this._onDrop); _off(ownerDocument, 'touchend', this._onDrop);
_off(ownerDocument, 'pointerup', this._onDrop);
_off(ownerDocument, 'touchcancel', this._onDrop); _off(ownerDocument, 'touchcancel', this._onDrop);
}, },
@ -1039,6 +1048,7 @@
_off(el, 'mousedown', this._onTapStart); _off(el, 'mousedown', this._onTapStart);
_off(el, 'touchstart', this._onTapStart); _off(el, 'touchstart', this._onTapStart);
_off(el, 'pointerdown', this._onTapStart);
if (this.nativeDraggable) { if (this.nativeDraggable) {
_off(el, 'dragover', this); _off(el, 'dragover', this);

Loading…
Cancel
Save