Browse Source

send insertAfter information in move hook

pull/1084/head
desmaisons_david 8 years ago
parent
commit
8451985bd8
  1. 29
      Sortable.js
  2. 3
      Sortable.min.js

29
Sortable.js

@ -384,7 +384,7 @@
dragEl = target;
parentEl = dragEl.parentNode;
nextEl = dragEl.nextSibling;
lastDownEl = target
lastDownEl = target;
activeGroup = options.group;
oldIndex = startIndex;
@ -763,20 +763,10 @@
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
;
if (moveVector !== false) {
_silent = true;
setTimeout(_unsilent, 30);
_cloneHide(activeSortable, isOwner);
if (moveVector === 1 || moveVector === -1) {
after = (moveVector === 1);
}
else if (floating) {
if (floating) {
var elTop = dragEl.offsetTop,
tgTop = target.offsetTop;
@ -792,6 +782,18 @@
after = (nextSibling !== dragEl) && !isLong || halfway && isLong;
}
var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
if (moveVector !== false) {
if (moveVector === 1 || moveVector === -1) {
after = (moveVector === 1);
}
_silent = true;
setTimeout(_unsilent, 30);
_cloneHide(activeSortable, isOwner);
if (!dragEl.contains(el)) {
if (after && !nextSibling) {
el.appendChild(dragEl);
@ -1247,7 +1249,7 @@
}
function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvt) {
function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvt, insertAfter) {
var evt,
sortable = fromEl[expando],
onMoveFn = sortable.options.onMove,
@ -1262,6 +1264,7 @@
evt.draggedRect = dragRect;
evt.related = targetEl || toEl;
evt.relatedRect = targetRect || toEl.getBoundingClientRect();
evt.insertAfter = insertAfter;
fromEl.dispatchEvent(evt);

3
Sortable.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save