Browse Source

#1017: + revertClone

pull/798/merge
Lebedev Konstantin 8 years ago
parent
commit
b0af97c1ac
  1. 27
      Sortable.js

27
Sortable.js

@ -207,6 +207,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;
} }
@ -678,7 +679,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) {
@ -703,7 +704,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)) {
@ -740,7 +741,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);
@ -784,6 +785,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,'
@ -1059,10 +1064,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;
} }
} }
@ -1339,7 +1355,6 @@
); );
} }
// Export utils // Export utils
Sortable.utils = { Sortable.utils = {
on: _on, on: _on,

Loading…
Cancel
Save