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