Skip to content

Commit 87a5f52

Browse files
author
pc-david\david.desmaisons
committed
Adding improvement linked to issue#21
1 parent 1fd7ebf commit 87a5f52

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

dist/vuedraggable.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
6565
type: Array,
6666
required: false,
6767
default: null
68+
},
69+
clone: {
70+
type: Function,
71+
default: function _default(original) {
72+
return original;
73+
}
6874
}
6975
};
7076

@@ -116,7 +122,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
116122
currentIndex: currentIndex,
117123
element: element
118124
};
119-
evt.item._underlying_vm_ = element;
125+
evt.item._underlying_vm_ = this.clone(element);
120126
},
121127
onDragAdd: function onDragAdd(evt) {
122128
var element = evt.item._underlying_vm_;
@@ -163,13 +169,15 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
163169
return draggableComponent;
164170
}
165171

166-
if (typeof exports == "object") {
167-
var Sortable = require("sortablejs")
168-
module.exports = buildDraggable(Sortable)
172+
if (typeof exports == "object") {
173+
var Sortable = require("sortablejs");
174+
module.exports = buildDraggable(Sortable);
169175
} else if (typeof define == "function" && define.amd) {
170-
define(['Sortable'], function(Sortable) { return buildDraggable(Sortable);});
171-
} else if ( window && (window.Vue) && (window.Sortable)) {
172-
var draggable = buildDraggable(window.Sortable)
173-
Vue.component('draggable', draggable)
176+
define(['Sortable'], function (Sortable) {
177+
return buildDraggable(Sortable);
178+
});
179+
} else if (window && window.Vue && window.Sortable) {
180+
var draggable = buildDraggable(window.Sortable);
181+
Vue.component('draggable', draggable);
174182
}
175183
})();

dist/vuedraggable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/script/complex.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ var vm = new Vue({
1515
},
1616
replace: function(){
1717
this.list=[{name:'Edgard'}]
18+
},
19+
clone: function(el){
20+
return {
21+
name : el.name + ' cloned'
22+
}
1823
}
1924
}
2025
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuedraggable",
3-
"version": "2.0.4",
3+
"version": "2.1.0",
44
"description": "draggable component for vue",
55
"main": "dist/vuedraggable.js",
66
"files": [

src/vuedraggable.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
type: Array,
5656
required: false,
5757
default: null
58+
},
59+
clone: {
60+
type: Function,
61+
default : (original) => { return original;}
5862
}
5963
}
6064

@@ -106,7 +110,7 @@
106110
currentIndex,
107111
element
108112
}
109-
evt.item._underlying_vm_ = element
113+
evt.item._underlying_vm_ = this.clone(element)
110114
},
111115

112116
onDragAdd (evt) {

0 commit comments

Comments
 (0)