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 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 // Element is dropped into the list from another list
onAdd: function (/**Event*/evt) { onAdd: function (/**Event*/evt) {
var itemEl = evt.item; // dragged HTMLElement var itemEl = evt.item; // dragged HTMLElement

11
Sortable.js

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

Loading…
Cancel
Save