Browse Source

#1017: + revertClone

revertClone
Lebedev Konstantin 8 years ago
parent
commit
0bd46593ff
  1. 27
      Sortable.js

27
Sortable.js

@ -210,6 +210,7 @@
group.name = originalGroup.name; group.name = originalGroup.name;
group.checkPull = toFn(originalGroup.pull, true); group.checkPull = toFn(originalGroup.pull, true);
group.checkPut = toFn(originalGroup.put); group.checkPut = toFn(originalGroup.put);
group.revertClone = originalGroup.revertClone;
options.group = group; options.group = group;
} }
@ -709,7 +710,7 @@
putSortable = this; putSortable = this;
if (revert) { if (revert) {
_cloneHide(true); _cloneHide(activeSortable, true);
parentEl = rootEl; // actualization parentEl = rootEl; // actualization
if (cloneEl || nextEl) { if (cloneEl || nextEl) {
@ -734,7 +735,7 @@
targetRect = target.getBoundingClientRect(); targetRect = target.getBoundingClientRect();
} }
_cloneHide(isOwner); _cloneHide(activeSortable, isOwner);
if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt) !== false) { if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt) !== false) {
if (!dragEl.contains(el)) { if (!dragEl.contains(el)) {
@ -771,7 +772,7 @@
_silent = true; _silent = true;
setTimeout(_unsilent, 30); setTimeout(_unsilent, 30);
_cloneHide(isOwner); _cloneHide(activeSortable, isOwner);
if (moveVector === 1 || moveVector === -1) { if (moveVector === 1 || moveVector === -1) {
after = (moveVector === 1); after = (moveVector === 1);
@ -815,6 +816,10 @@
if (ms) { if (ms) {
var currentRect = target.getBoundingClientRect(); var currentRect = target.getBoundingClientRect();
if (prevRect.nodeType === 1) {
prevRect = prevRect.getBoundingClientRect();
}
_css(target, 'transition', 'none'); _css(target, 'transition', 'none');
_css(target, 'transform', 'translate3d(' _css(target, 'transform', 'translate3d('
+ (prevRect.left - currentRect.left) + 'px,' + (prevRect.left - currentRect.left) + 'px,'
@ -1094,10 +1099,21 @@
}; };
function _cloneHide(state) { function _cloneHide(sortable, state) {
if (cloneEl && (cloneEl.state !== state)) { if (cloneEl && (cloneEl.state !== state)) {
_css(cloneEl, 'display', state ? 'none' : ''); _css(cloneEl, 'display', state ? 'none' : '');
!state && cloneEl.state && rootEl.insertBefore(cloneEl, dragEl);
if (!state) {
if (cloneEl.state) {
if (sortable.options.group.revertClone) {
rootEl.insertBefore(cloneEl, nextEl);
sortable._animate(dragEl, cloneEl);
} else {
rootEl.insertBefore(cloneEl, dragEl);
}
}
}
cloneEl.state = state; cloneEl.state = state;
} }
} }
@ -1374,7 +1390,6 @@
); );
} }
// Export utils // Export utils
Sortable.utils = { Sortable.utils = {
on: _on, on: _on,

Loading…
Cancel
Save