Browse Source

Merge branch 'old-browser' into dev

pull/251/merge
RubaXa 10 years ago
parent
commit
52e02773a5
  1. 38
      Sortable.js
  2. 2
      Sortable.min.js

38
Sortable.js

@ -48,7 +48,9 @@
win = window,
document = win.document,
parseInt = win.parseInt,
supportIEdnd = !!document.createElement('div').dragDrop,
supportDraggable = !!('draggable' in document.createElement('div')),
_silent = false,
@ -154,7 +156,6 @@
// Bind events
_on(el, 'mousedown', this._onTapStart);
_on(el, 'touchstart', this._onTapStart);
supportIEdnd && _on(el, 'selectstart', this._onTapStart);
_on(el, 'dragover', this);
_on(el, 'dragenter', this);
@ -231,9 +232,6 @@
// Prepare `dragstart`
if (target && !dragEl && (target.parentNode === el)) {
// IE 9 Support
(type === 'selectstart') && target.dragDrop();
tapEvt = evt;
rootEl = this.el;
@ -256,7 +254,7 @@
clientY: touch.clientY
};
this._onDragStart(tapEvt, true);
this._onDragStart(tapEvt, 'touch');
evt.preventDefault();
}
@ -267,6 +265,10 @@
_on(dragEl, 'dragend', this);
_on(rootEl, 'dragstart', this._onDragStart);
if (!supportDraggable) {
this._onDragStart(tapEvt, true);
}
try {
if (document.selection) {
document.selection.empty();
@ -315,10 +317,10 @@
_onTouchMove: function (/**TouchEvent*/evt) {
if (tapEvt) {
var touch = evt.touches[0],
var touch = evt.touches ? evt.touches[0] : evt,
dx = touch.clientX - tapEvt.clientX,
dy = touch.clientY - tapEvt.clientY,
translate3d = 'translate3d(' + dx + 'px,' + dy + 'px,0)';
translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)';
touchEvt = touch;
@ -333,7 +335,7 @@
},
_onDragStart: function (/**Event*/evt, /**boolean*/isTouch) {
_onDragStart: function (/**Event*/evt, /**boolean*/useFallback) {
var dataTransfer = evt.dataTransfer,
options = this.options;
@ -345,7 +347,7 @@
rootEl.insertBefore(cloneEl, dragEl);
}
if (isTouch) {
if (useFallback) {
var rect = dragEl.getBoundingClientRect(),
css = _css(dragEl),
ghostRect;
@ -367,10 +369,16 @@
_css(ghostEl, 'width', rect.width * 2 - ghostRect.width);
_css(ghostEl, 'height', rect.height * 2 - ghostRect.height);
// Bind touch events
_on(document, 'touchmove', this._onTouchMove);
_on(document, 'touchend', this._onDrop);
_on(document, 'touchcancel', this._onDrop);
if (useFallback === 'touch') {
// Bind touch events
_on(document, 'touchmove', this._onTouchMove);
_on(document, 'touchend', this._onDrop);
_on(document, 'touchcancel', this._onDrop);
} else {
// Old brwoser
_on(document, 'mousemove', this._onTouchMove);
_on(document, 'mouseup', this._onDrop);
}
this._loopId = setInterval(this._emulateDragOver, 150);
}
@ -594,6 +602,7 @@
// Unbind events
_off(document, 'drop', this);
_off(document, 'mousemove', this._onTouchMove);
_off(el, 'dragstart', this._onDragStart);
this._offUpEvents();
@ -772,7 +781,6 @@
_off(el, 'mousedown', this._onTapStart);
_off(el, 'touchstart', this._onTapStart);
_off(el, 'selectstart', this._onTapStart);
_off(el, 'dragover', this);
_off(el, 'dragenter', this);

2
Sortable.min.js vendored

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