Browse Source

Merge pull request #457 from sp-kilobug/sp-kilobug-patch-1

remove drag/drop handlers in forceFallback mode
pull/408/merge
Lebedev Konstantin 10 years ago
parent
commit
1cd9f9109c
  1. 33
      Sortable.js

33
Sortable.js

@ -57,8 +57,6 @@
document = win.document, document = win.document,
parseInt = win.parseInt, parseInt = win.parseInt,
supportDraggable = !!('draggable' in document.createElement('div')),
_silent = false, _silent = false,
abs = Math.abs, abs = Math.abs,
@ -191,6 +189,11 @@
!(name in options) && (options[name] = defaults[name]); !(name in options) && (options[name] = defaults[name]);
} }
if (options.forceFallback) {
this.nativeDragMode = false;
} else {
this.nativeDragMode = !!('draggable' in document.createElement('div'));
}
var group = options.group; var group = options.group;
@ -221,8 +224,10 @@
_on(el, 'mousedown', this._onTapStart); _on(el, 'mousedown', this._onTapStart);
_on(el, 'touchstart', this._onTapStart); _on(el, 'touchstart', this._onTapStart);
_on(el, 'dragover', this); if (this.nativeDragMode) {
_on(el, 'dragenter', this); _on(el, 'dragover', this);
_on(el, 'dragenter', this);
}
touchDragOverListeners.push(this._onDragOver); touchDragOverListeners.push(this._onDragOver);
@ -368,7 +373,7 @@
this._onDragStart(tapEvt, 'touch'); this._onDragStart(tapEvt, 'touch');
} }
else if (!supportDraggable || this.options.forceFallback) { else if (!this.nativeDragMode) {
this._onDragStart(tapEvt, true); this._onDragStart(tapEvt, true);
} }
else { else {
@ -532,7 +537,6 @@
_on(document, 'drop', this); _on(document, 'drop', this);
setTimeout(this._dragStarted, 0); setTimeout(this._dragStarted, 0);
} }
}, },
_onDragOver: function (/**Event*/evt) { _onDragOver: function (/**Event*/evt) {
@ -695,9 +699,12 @@
clearTimeout(this._dragStartTimer); clearTimeout(this._dragStartTimer);
// Unbind events // Unbind events
_off(document, 'drop', this);
_off(document, 'mousemove', this._onTouchMove); _off(document, 'mousemove', this._onTouchMove);
_off(el, 'dragstart', this._onDragStart);
if (this.nativeDragMode) {
_off(document, 'drop', this);
_off(el, 'dragstart', this._onDragStart);
}
this._offUpEvents(); this._offUpEvents();
@ -710,7 +717,9 @@
ghostEl && ghostEl.parentNode.removeChild(ghostEl); ghostEl && ghostEl.parentNode.removeChild(ghostEl);
if (dragEl) { if (dragEl) {
_off(dragEl, 'dragend', this); if (this.nativeDragMode) {
_off(dragEl, 'dragend', this);
}
_disableDraggable(dragEl); _disableDraggable(dragEl);
_toggleClass(dragEl, this.options.ghostClass, false); _toggleClass(dragEl, this.options.ghostClass, false);
@ -888,8 +897,10 @@
_off(el, 'mousedown', this._onTapStart); _off(el, 'mousedown', this._onTapStart);
_off(el, 'touchstart', this._onTapStart); _off(el, 'touchstart', this._onTapStart);
_off(el, 'dragover', this); if (this.nativeDragMode) {
_off(el, 'dragenter', this); _off(el, 'dragover', this);
_off(el, 'dragenter', this);
}
// Remove draggable attributes // Remove draggable attributes
Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) { Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {

Loading…
Cancel
Save