Browse Source

#134: fixed destroy

pull/168/head
RubaXa 10 years ago
parent
commit
332fc25db8
  1. 24
      Sortable.js

24
Sortable.js

@ -49,14 +49,14 @@
_silent = false, _silent = false,
_dispatchEvent = function (rootEl, name, targetEl, fromEl) { _dispatchEvent = function (el, name, targetEl, fromEl) {
var evt = document.createEvent('Event'); var evt = document.createEvent('Event');
evt.initEvent(name, true, true); evt.initEvent(name, true, true);
evt.item = targetEl || rootEl; evt.item = targetEl || el;
evt.from = fromEl || rootEl; evt.from = fromEl || el;
rootEl.dispatchEvent(evt); el.dispatchEvent(evt);
}, },
_customEvents = 'onAdd onUpdate onRemove onStart onEnd onFilter onSort'.split(' '), _customEvents = 'onAdd onUpdate onRemove onStart onEnd onFilter onSort'.split(' '),
@ -357,7 +357,7 @@
dataTransfer.effectAllowed = 'move'; dataTransfer.effectAllowed = 'move';
options.setData && options.setData.call(this, dataTransfer, dragEl); options.setData && options.setData.call(this, dataTransfer, dragEl);
_on(document, 'drop', this._onDrop); _on(document, 'drop', this);
} }
setTimeout(this._applyEffects, 0); setTimeout(this._applyEffects, 0);
@ -365,7 +365,7 @@
scrollEl = options.scroll; scrollEl = options.scroll;
if (scrollEl === true) { if (scrollEl === true) {
scrollEl = rootEl; scrollEl = dragEl;
do { do {
if ((scrollEl.offsetWidth < scrollEl.scrollWidth) || if ((scrollEl.offsetWidth < scrollEl.scrollWidth) ||
@ -544,16 +544,17 @@
}, },
_onDrop: function (/**Event*/evt) { _onDrop: function (/**Event*/evt) {
var el = this.el;
clearInterval(this._loopId); clearInterval(this._loopId);
clearInterval(autoScroll.pid); clearInterval(autoScroll.pid);
// Unbind events // Unbind events
_off(document, 'drop', this._onDrop); _off(document, 'drop', this);
_off(document, 'dragover', this); _off(document, 'dragover', this);
_off(rootEl, 'dragend', this._onDrop); _off(el, 'dragend', this._onDrop);
_off(rootEl, 'dragstart', this._onDragStart); _off(el, 'dragstart', this._onDragStart);
_off(rootEl, 'selectstart', this._onTapStart);
this._offUpEvents(); this._offUpEvents();
@ -616,6 +617,9 @@
this._onDrag(evt); this._onDrag(evt);
_globalDragOver(evt); _globalDragOver(evt);
} }
else if (type === 'drop') {
this._onDrop(evt);
}
}, },

Loading…
Cancel
Save