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 animation: 150, // ms, animation speed moving items when sorting, `0` — without animation
handle: ".my-handle", // Drag handle selector within list items handle: ".my-handle", // Drag handle selector within list items
filter: ".ignore-elements", // Selectors that do not lead to dragging (String or Function) 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 draggable: ".item", // Specifies which items inside the element should be draggable
ghostClass: "sortable-ghost", // Class name for the drop placeholder ghostClass: "sortable-ghost", // Class name for the drop placeholder
chosenClass: "sortable-chosen", // Class name for the chosen item chosenClass: "sortable-chosen", // Class name for the chosen item

6
Sortable.js

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

Loading…
Cancel
Save