Browse Source

Merge pull request #881 from kalaspuffar/manually_handle_updates

Manually handle updates
pull/832/merge
Lebedev Konstantin 9 years ago committed by GitHub
parent
commit
b7cc23841d
  1. 2
      README.md
  2. 5
      Sortable.html

2
README.md

@ -526,7 +526,7 @@ The sortable/draggable bindingHandlers supports the same syntax as Knockouts bui
Other attributes are:
* options: an object that contains settings for the underlaying sortable, ie `group`,`handle`, events etc.
* collection: if your `foreach` array is a computed then you would supply the underlaying observableArray that you would like to sort here.
* manuallyHandleUpdateEvents: a boolean to turn off the change events on update that other polymer elements listen to.
---

5
Sortable.html

@ -30,6 +30,7 @@
forceFallback : { type: Boolean, value: false, observer: "forceFallbackChanged" },
fallbackClass : { type: String, value: "sortable-fallback", observer: "fallbackClassChanged" },
fallbackOnBody : { type: Boolean, value: false, observer: "fallbackOnBodyChanged" },
manuallyHandleUpdateEvents : { type: Boolean, value: false },
draggable : {},
scroll : {}
},
@ -78,8 +79,12 @@
this.sortable = Sortable.create(this, Object.assign(options, {
onUpdate: e => {
if (template) {
if(manuallyHandleUpdateEvents) {
template.items.splice(e.newIndex, 0, template.items.splice(e.oldIndex, 1)[0]);
} else {
template.splice("items", e.newIndex, 0, template.splice("items", e.oldIndex, 1)[0])
}
}
this.fire("update", e)
},

Loading…
Cancel
Save