|
|
|
@ -56,7 +56,8 @@
|
|
|
|
|
moved, |
|
|
|
|
|
|
|
|
|
/** @const */ |
|
|
|
|
RSPACE = /\s+/g, |
|
|
|
|
R_SPACE = /\s+/g, |
|
|
|
|
R_FLOAT = /left|right|inline/, |
|
|
|
|
|
|
|
|
|
expando = 'Sortable' + (new Date).getTime(), |
|
|
|
|
|
|
|
|
@ -419,6 +420,7 @@
|
|
|
|
|
_on(ownerDocument, 'touchend', _this._onDrop); |
|
|
|
|
_on(ownerDocument, 'touchcancel', _this._onDrop); |
|
|
|
|
_on(ownerDocument, 'pointercancel', _this._onDrop); |
|
|
|
|
_on(ownerDocument, 'selectstart', _this); |
|
|
|
|
|
|
|
|
|
if (options.delay) { |
|
|
|
|
// If the user moves the pointer or let go the click or touch
|
|
|
|
@ -436,9 +438,7 @@
|
|
|
|
|
dragStartFn(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (options.forceFallback) { |
|
|
|
|
evt.preventDefault(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -456,6 +456,7 @@
|
|
|
|
|
|
|
|
|
|
_triggerDragStart: function (/** Event */evt, /** Touch */touch) { |
|
|
|
|
touch = touch || (evt.pointerType == 'touch' ? evt : null); |
|
|
|
|
|
|
|
|
|
if (touch) { |
|
|
|
|
// Touch device support
|
|
|
|
|
tapEvt = { |
|
|
|
@ -674,6 +675,7 @@
|
|
|
|
|
group = options.group, |
|
|
|
|
activeSortable = Sortable.active, |
|
|
|
|
isOwner = (activeGroup === group), |
|
|
|
|
isMovingBetweenSortable = false, |
|
|
|
|
canSort = options.sort; |
|
|
|
|
|
|
|
|
|
if (evt.preventDefault !== void 0) { |
|
|
|
@ -681,6 +683,10 @@
|
|
|
|
|
!options.dragoverBubble && evt.stopPropagation(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dragEl.animated) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
moved = true; |
|
|
|
|
|
|
|
|
|
if (activeSortable && !options.disabled && |
|
|
|
@ -705,7 +711,11 @@
|
|
|
|
|
|
|
|
|
|
target = _closest(evt.target, options.draggable, el); |
|
|
|
|
dragRect = dragEl.getBoundingClientRect(); |
|
|
|
|
putSortable = this; |
|
|
|
|
|
|
|
|
|
if (putSortable !== this) { |
|
|
|
|
putSortable = this; |
|
|
|
|
isMovingBetweenSortable = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (revert) { |
|
|
|
|
_cloneHide(activeSortable, true); |
|
|
|
@ -756,14 +766,14 @@
|
|
|
|
|
|
|
|
|
|
var width = targetRect.right - targetRect.left, |
|
|
|
|
height = targetRect.bottom - targetRect.top, |
|
|
|
|
floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) |
|
|
|
|
floating = R_FLOAT.test(lastCSS.cssFloat + lastCSS.display) |
|
|
|
|
|| (lastParentCSS.display == 'flex' && lastParentCSS['flex-direction'].indexOf('row') === 0), |
|
|
|
|
isWide = (target.offsetWidth > dragEl.offsetWidth), |
|
|
|
|
isLong = (target.offsetHeight > dragEl.offsetHeight), |
|
|
|
|
halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5, |
|
|
|
|
nextSibling = target.nextElementSibling, |
|
|
|
|
moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt), |
|
|
|
|
after |
|
|
|
|
after = false |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
if (moveVector !== false) { |
|
|
|
@ -787,7 +797,7 @@
|
|
|
|
|
} else { |
|
|
|
|
after = tgTop > elTop; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
} else if (!isMovingBetweenSortable) { |
|
|
|
|
after = (nextSibling !== dragEl) && !isLong || halfway && isLong; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -847,6 +857,7 @@
|
|
|
|
|
_off(ownerDocument, 'touchend', this._onDrop); |
|
|
|
|
_off(ownerDocument, 'pointerup', this._onDrop); |
|
|
|
|
_off(ownerDocument, 'touchcancel', this._onDrop); |
|
|
|
|
_off(ownerDocument, 'selectstart', this); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_onDrop: function (/**Event*/evt) { |
|
|
|
@ -964,16 +975,23 @@
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
handleEvent: function (/**Event*/evt) { |
|
|
|
|
var type = evt.type; |
|
|
|
|
switch (evt.type) { |
|
|
|
|
case 'drop': |
|
|
|
|
case 'dragend': |
|
|
|
|
this._onDrop(evt); |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'dragover': |
|
|
|
|
case 'dragenter': |
|
|
|
|
if (dragEl) { |
|
|
|
|
this._onDragOver(evt); |
|
|
|
|
_globalDragOver(evt); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
if (type === 'dragover' || type === 'dragenter') { |
|
|
|
|
if (dragEl) { |
|
|
|
|
this._onDragOver(evt); |
|
|
|
|
_globalDragOver(evt); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if (type === 'drop' || type === 'dragend') { |
|
|
|
|
this._onDrop(evt); |
|
|
|
|
case 'selectstart': |
|
|
|
|
evt.preventDefault(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -1168,8 +1186,8 @@
|
|
|
|
|
el.classList[state ? 'add' : 'remove'](name); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
var className = (' ' + el.className + ' ').replace(RSPACE, ' ').replace(' ' + name + ' ', ' '); |
|
|
|
|
el.className = (className + (state ? ' ' + name : '')).replace(RSPACE, ' '); |
|
|
|
|
var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' '); |
|
|
|
|
el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' '); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|