Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions polymer-sortablejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,23 @@
fallbackClass : { type: String, value: "sortable-fallback", observer: "fallbackClassChanged" },
fallbackOnBody : { type: Boolean, value: false, observer: "fallbackOnBodyChanged" },
draggable : {},
scroll : {}
scroll : {},

/**
* `delegateAdd` set true to delegate adding item to the template to other part of the application
*/
delegateAdd: {
type: Boolean,
value: false
},

/**
* `delegateAdd` set true to delegate removing item to the template to other part of the application
*/
delegateRemove: {
type: Boolean,
value: false
}
},

created: function() {
Expand Down Expand Up @@ -79,19 +95,19 @@
onUpdate: function (e) {
if (template) {
template.splice("items", e.newIndex, 0, template.splice("items", e.oldIndex, 1)[0]);
/*
/*
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);
},

onAdd: function(e) {
if (template) {
if (template && !_this.delegateAdd) {
var froms = e.from.querySelectorAll("template[is='dom-repeat']");
var from = froms[froms.length-1];
var model = from.modelForElement(e.item);
Expand All @@ -106,8 +122,10 @@
if (e.target.group.pull === 'clone') {
return false;
}
if (template) {
var item = template.splice("items", e.oldIndex, 1)[0];
if (template) {
if (!_this.delegateRemove) {
var item = template.splice("items", e.oldIndex, 1)[0];
}
e.model = {item: item};
}
_this.fire("remove", e);
Expand Down