Browse Source

+ draft

leave-enter
Lebedev Konstantin 8 years ago
parent
commit
0f573bd7ff
  1. 6
      README.md
  2. 11
      Sortable.js

6
README.md

@ -125,6 +125,12 @@ var sortable = new Sortable(el, {
evt.newIndex; // element's new index within parent
},
// Element enters into sortable
onEnter: function (/**Event*/evt) {},
// Element leaves from sortable
onLeave: function (/**Event*/evt) {},
// Element is dropped into the list from another list
onAdd: function (/**Event*/evt) {
var itemEl = evt.item; // dragged HTMLElement

11
Sortable.js

@ -33,6 +33,7 @@
rootEl,
nextEl,
lastDownEl,
lastOver,
scrollEl,
scrollParentEl,
@ -456,6 +457,7 @@
_triggerDragStart: function (/** Event */evt, /** Touch */touch) {
touch = touch || (evt.pointerType == 'touch' ? evt : null);
if (touch) {
// Touch device support
tapEvt = {
@ -495,10 +497,12 @@
_toggleClass(dragEl, options.ghostClass, true);
_toggleClass(dragEl, options.dragClass, false);
lastOver = this;
Sortable.active = this;
// Drag start event
_dispatchEvent(this, rootEl, 'start', dragEl, rootEl, oldIndex);
_dispatchEvent(this, rootEl, 'enter', dragEl, rootEl, oldIndex);
} else {
this._nulling();
}
@ -683,6 +687,12 @@
moved = true;
if (lastOver !== this) {
_dispatchEvent(lastOver, lastOver.el, 'leave', dragEl);
_dispatchEvent(this, el, 'enter', dragEl, lastOver.el);
lastOver = this;
}
if (activeSortable && !options.disabled &&
(isOwner
? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list
@ -945,6 +955,7 @@
nextEl =
cloneEl =
lastDownEl =
lastOver =
scrollEl =
scrollParentEl =

Loading…
Cancel
Save