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