Browse Source

#1029: + preventOnFilter

revertClone
Lebedev Konstantin 8 years ago
parent
commit
1aa0121c31
  1. 1
      README.md
  2. 6
      Sortable.js

1
README.md

@ -87,6 +87,7 @@ var sortable = new Sortable(el, {
animation: 150, // ms, animation speed moving items when sorting, `0` — without animation
handle: ".my-handle", // Drag handle selector within list items
filter: ".ignore-elements", // Selectors that do not lead to dragging (String or Function)
preventOnFilter: true, // Call `event.preventDefault()` when triggered `filter`
draggable: ".item", // Specifies which items inside the element should be draggable
ghostClass: "sortable-ghost", // Class name for the drop placeholder
chosenClass: "sortable-chosen", // Class name for the chosen item

6
Sortable.js

@ -249,6 +249,7 @@
dragClass: 'sortable-drag',
ignore: 'a, img',
filter: null,
preventOnFilter: true,
animation: 0,
setData: function (dataTransfer, dragEl) {
dataTransfer.setData('Text', dragEl.textContent);
@ -306,6 +307,7 @@
var _this = this,
el = this.el,
options = this.options,
preventOnFilter = preventOnFilter.options,
type = evt.type,
touch = evt.touches && evt.touches[0],
target = (touch || evt).target,
@ -339,7 +341,7 @@
if (typeof filter === 'function') {
if (filter.call(this, evt, target, this)) {
_dispatchEvent(_this, originalTarget, 'filter', target, el, startIndex);
evt.preventDefault();
preventOnFilter && evt.preventDefault();
return; // cancel dnd
}
}
@ -354,7 +356,7 @@
});
if (filter) {
evt.preventDefault();
preventOnFilter && evt.preventDefault();
return; // cancel dnd
}
}

Loading…
Cancel
Save