Browse Source

IE11 support

pull/49/head
Marius Petcu 11 years ago
parent
commit
d272d12e78
  1. 22
      Sortable.js

22
Sortable.js

@ -104,6 +104,10 @@
_on(el, 'dragover', this._onDragOver); _on(el, 'dragover', this._onDragOver);
_on(el, 'dragenter', this._onDragOver); _on(el, 'dragenter', this._onDragOver);
_on(el, 'pointerdown', this._onTapStart);
_css(el, 'touch-action', 'none');
_css(el, '-ms-touch-action', 'none');
touchDragOverListeners.push(this._onDragOver); touchDragOverListeners.push(this._onDragOver);
} }
@ -158,7 +162,11 @@
this._onDragStart(tapEvt, true); this._onDragStart(tapEvt, true);
evt.preventDefault(); evt.preventDefault();
} }
if (evt.type == 'pointerdown') {
this._onDragStart(tapEvt, true);
evt.preventDefault();
}
_on(this.el, 'dragstart', this._onDragStart); _on(this.el, 'dragstart', this._onDragStart);
_on(this.el, 'dragend', this._onDrop); _on(this.el, 'dragend', this._onDrop);
@ -211,16 +219,19 @@
}, },
_onTouchMove: function (evt/**TouchEvent*/){ _onTouchMove: function (evt/**TouchEvent|PointerEvent*/){
if( tapEvt ){ if( tapEvt ){
var var
touch = evt.touches[0] touch = (evt.type == 'pointermove') ? evt : evt.touches[0]
, dx = touch.clientX - tapEvt.clientX , dx = touch.clientX - tapEvt.clientX
, dy = touch.clientY - tapEvt.clientY , dy = touch.clientY - tapEvt.clientY
; ;
touchEvt = touch; touchEvt = touch;
_css(ghostEl, 'webkitTransform', 'translate3d('+dx+'px,'+dy+'px,0)'); _css(ghostEl, 'webkitTransform', 'translate3d('+dx+'px,'+dy+'px,0)');
_css(ghostEl, 'mozTransform', 'translate3d('+dx+'px,'+dy+'px,0)');
_css(ghostEl, 'msTransform', 'translate3d('+dx+'px,'+dy+'px,0)');
_css(ghostEl, 'transform', 'translate3d('+dx+'px,'+dy+'px,0)');
} }
}, },
@ -263,6 +274,8 @@
// Bind touch events // Bind touch events
_on(document, 'touchmove', this._onTouchMove); _on(document, 'touchmove', this._onTouchMove);
_on(document, 'touchend', this._onDrop); _on(document, 'touchend', this._onDrop);
_on(document, 'pointermove', this._onTouchMove);
_on(document, 'pointerup', this._onDrop);
this._loopId = setInterval(this._emulateDragOver, 150); this._loopId = setInterval(this._emulateDragOver, 150);
} }
@ -339,6 +352,8 @@
_off(document, 'touchmove', this._onTouchMove); _off(document, 'touchmove', this._onTouchMove);
_off(document, 'touchend', this._onDrop); _off(document, 'touchend', this._onDrop);
_off(document, 'pointermove', this._onTouchMove);
_off(document, 'pointerup', this._onDrop);
if( evt ){ if( evt ){
@ -393,6 +408,7 @@
_off(el, 'mousedown', this._onTapStart); _off(el, 'mousedown', this._onTapStart);
_off(el, 'touchstart', this._onTapStart); _off(el, 'touchstart', this._onTapStart);
_off(el, 'selectstart', this._onTapStart); _off(el, 'selectstart', this._onTapStart);
_off(el, 'pointerdown', this._onTapStart);
_off(el, 'dragover', this._onDragOver); _off(el, 'dragover', this._onDragOver);
_off(el, 'dragenter', this._onDragOver); _off(el, 'dragenter', this._onDragOver);

Loading…
Cancel
Save