Browse Source

Merge pull request #834 from joual/dev

Add the original mouse event as parameter in onMove()
pull/832/head
Lebedev Konstantin 9 years ago committed by GitHub
parent
commit
48f3a11f42
  1. 3
      README.md
  2. 8
      Sortable.js
  3. 2
      Sortable.min.js

3
README.md

@ -126,12 +126,13 @@ var sortable = new Sortable(el, {
}, },
// Event when you move an item in the list or between lists // Event when you move an item in the list or between lists
onMove: function (/**Event*/evt) { onMove: function (/**Event*/evt, /**Event*/originalEvent) {
// Example: http://jsbin.com/tuyafe/1/edit?js,output // Example: http://jsbin.com/tuyafe/1/edit?js,output
evt.dragged; // dragged HTMLElement evt.dragged; // dragged HTMLElement
evt.draggedRect; // TextRectangle {left, top, right и bottom} evt.draggedRect; // TextRectangle {left, top, right и bottom}
evt.related; // HTMLElement on which have guided evt.related; // HTMLElement on which have guided
evt.relatedRect; // TextRectangle evt.relatedRect; // TextRectangle
originalEvent.clientY; // mouse position
// return false; — for cancel // return false; — for cancel
}, },

8
Sortable.js

@ -681,7 +681,7 @@
_cloneHide(isOwner); _cloneHide(isOwner);
if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect) !== false) { if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt) !== false) {
if (!dragEl.contains(el)) { if (!dragEl.contains(el)) {
el.appendChild(dragEl); el.appendChild(dragEl);
parentEl = el; // actualization parentEl = el; // actualization
@ -708,7 +708,7 @@
isLong = (target.offsetHeight > dragEl.offsetHeight), isLong = (target.offsetHeight > dragEl.offsetHeight),
halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5, halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5,
nextSibling = target.nextElementSibling, nextSibling = target.nextElementSibling,
moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect), moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt),
after after
; ;
@ -1158,7 +1158,7 @@
} }
function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect) { function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvt) {
var evt, var evt,
sortable = fromEl[expando], sortable = fromEl[expando],
onMoveFn = sortable.options.onMove, onMoveFn = sortable.options.onMove,
@ -1177,7 +1177,7 @@
fromEl.dispatchEvent(evt); fromEl.dispatchEvent(evt);
if (onMoveFn) { if (onMoveFn) {
retVal = onMoveFn.call(sortable, evt); retVal = onMoveFn.call(sortable, evt, originalEvt);
} }
return retVal; return retVal;

2
Sortable.min.js vendored

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