|
|
@ -83,7 +83,8 @@ |
|
|
|
draggable: el.children[0] && el.children[0].nodeName || (/[uo]l/i.test(el.nodeName) ? 'li' : '*'), |
|
|
|
draggable: el.children[0] && el.children[0].nodeName || (/[uo]l/i.test(el.nodeName) ? 'li' : '*'), |
|
|
|
ghostClass: 'sortable-ghost', |
|
|
|
ghostClass: 'sortable-ghost', |
|
|
|
ignore: 'a, img', |
|
|
|
ignore: 'a, img', |
|
|
|
filter: null |
|
|
|
filter: null, |
|
|
|
|
|
|
|
animation: 150 |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Set default options
|
|
|
|
// Set default options
|
|
|
@ -339,22 +340,21 @@ |
|
|
|
if( el.children.length === 0 || el.children[0] === ghostEl || (el === evt.target) && _ghostInBottom(el, evt) ){ |
|
|
|
if( el.children.length === 0 || el.children[0] === ghostEl || (el === evt.target) && _ghostInBottom(el, evt) ){ |
|
|
|
el.appendChild(dragEl); |
|
|
|
el.appendChild(dragEl); |
|
|
|
} |
|
|
|
} |
|
|
|
else if( target && target !== dragEl && (target.parentNode[expando] !== void 0) ){ |
|
|
|
else if( target && !target.animated && target !== dragEl && (target.parentNode[expando] !== void 0) ){ |
|
|
|
if( lastEl !== target ){ |
|
|
|
if( lastEl !== target ){ |
|
|
|
lastEl = target; |
|
|
|
lastEl = target; |
|
|
|
lastCSS = _css(target); |
|
|
|
lastCSS = _css(target); |
|
|
|
lastRect = target.getBoundingClientRect(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var |
|
|
|
var dragRect = dragEl.getBoundingClientRect() |
|
|
|
rect = lastRect |
|
|
|
, targetRect = target.getBoundingClientRect() |
|
|
|
, width = rect.right - rect.left |
|
|
|
, width = targetRect.right - targetRect.left |
|
|
|
, height = rect.bottom - rect.top |
|
|
|
, height = targetRect.bottom - targetRect.top |
|
|
|
, floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) |
|
|
|
, floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) |
|
|
|
, isWide = (target.offsetWidth > dragEl.offsetWidth) |
|
|
|
, isWide = (target.offsetWidth > dragEl.offsetWidth) |
|
|
|
, isLong = (target.offsetHeight > dragEl.offsetHeight) |
|
|
|
, isLong = (target.offsetHeight > dragEl.offsetHeight) |
|
|
|
, halfway = (floating ? (evt.clientX - rect.left)/width : (evt.clientY - rect.top)/height) > .5 |
|
|
|
, halfway = (floating ? (evt.clientX - targetRect.left)/width : (evt.clientY - targetRect.top)/height) > .5 |
|
|
|
, nextSibling = target.nextElementSibling |
|
|
|
, nextSibling = target.nextElementSibling |
|
|
|
, after |
|
|
|
, after |
|
|
|
; |
|
|
|
; |
|
|
@ -370,13 +370,40 @@ |
|
|
|
|
|
|
|
|
|
|
|
if( after && !nextSibling ){ |
|
|
|
if( after && !nextSibling ){ |
|
|
|
el.appendChild(dragEl); |
|
|
|
el.appendChild(dragEl); |
|
|
|
|
|
|
|
this._animate(dragRect, dragEl); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
target.parentNode.insertBefore(dragEl, after ? nextSibling : target); |
|
|
|
target.parentNode.insertBefore(dragEl, after ? nextSibling : target); |
|
|
|
|
|
|
|
this._animate(dragRect, dragEl); |
|
|
|
|
|
|
|
this._animate(targetRect, target); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_animate: function (prevRect, target) { |
|
|
|
|
|
|
|
var ms = this.options.animation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ms) { |
|
|
|
|
|
|
|
var currentRect = target.getBoundingClientRect(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_css(target, 'transform', 'translate3d(' |
|
|
|
|
|
|
|
+ (prevRect.left - currentRect.left) + 'px,' |
|
|
|
|
|
|
|
+ (prevRect.top - currentRect.top) + 'px,0)' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
target.offsetWidth; // repaint
|
|
|
|
|
|
|
|
target.animated = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_css(target, 'transition', 'transform ' + ms + 'ms'); |
|
|
|
|
|
|
|
_css(target, 'transform', 'translate3d(0,0,0)'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
|
|
_css(target, 'transition', ''); |
|
|
|
|
|
|
|
target.animated = false; |
|
|
|
|
|
|
|
}, ms); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
_offUpEvents: function () { |
|
|
|
_offUpEvents: function () { |
|
|
|
_off(document, 'mouseup', this._onDrop); |
|
|
|
_off(document, 'mouseup', this._onDrop); |
|
|
|
_off(document, 'touchmove', this._onTouchMove); |
|
|
|
_off(document, 'touchmove', this._onTouchMove); |
|
|
@ -680,8 +707,16 @@ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sortable.version = '0.5.1'; |
|
|
|
Sortable.version = '0.6.0'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Create sortable instance |
|
|
|
|
|
|
|
* @param {HTMLElement} el |
|
|
|
|
|
|
|
* @param {Object} [options] |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
Sortable.create = function (el, options) { |
|
|
|
|
|
|
|
return new Sortable(el, options) |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Export
|
|
|
|
// Export
|
|
|
|
return Sortable; |
|
|
|
return Sortable; |
|
|
|