From b88e7f5b1a11ab74c2c1ea07ceac84639f51faa1 Mon Sep 17 00:00:00 2001 From: desmaisons_david Date: Thu, 27 Oct 2016 21:31:38 -0200 Subject: [PATCH] Adding element prop issue 22 --- README.md | 6 +++++ dist/vuedraggable.js | 8 ++++-- dist/vuedraggable.min.js | 2 +- examples/Two_Lists.html | 2 +- examples/Two_Lists_Clone.html | 2 +- examples/Two_Lists_Clone_If.html | 2 +- examples/Two_Lists_If.html | 2 +- examples/Two_Lists_NoClone_If.html | 2 +- examples/Ul_example.html | 43 ++++++++++++++++++++++++++++++ package.json | 2 +- src/vuedraggable.js | 6 ++++- 11 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 examples/Ul_example.html diff --git a/README.md b/README.md index c1d2bb6d..92ab7e12 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,12 @@ Required: `false` Option used to inicialize the sortable object see: [sortable option documentation](https://github.com/RubaXa/Sortable#options)
Note that all the method starting by "on" will be ignored as draggable component expose the same API via events. +#### element +Type: `String`
+Default: `'div'` + +HTML root element that draggable component create as outer element for the included slot. + #### clone Type: `Function`
Required: `false`
diff --git a/dist/vuedraggable.js b/dist/vuedraggable.js index 980d2d31..9abac892 100644 --- a/dist/vuedraggable.js +++ b/dist/vuedraggable.js @@ -71,6 +71,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol default: function _default(original) { return original; } + }, + element: { + type: String, + default: 'div' } }; @@ -78,7 +82,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol props: props, render: function render(h) { - return h('div', null, this.$slots.default); + return h(this.element, null, this.$slots.default); }, mounted: function mounted() { var _this2 = this; @@ -169,7 +173,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol return draggableComponent; } - if (typeof exports == "object") { + if (typeof exports == "object") { var Sortable = require("sortablejs"); module.exports = buildDraggable(Sortable); } else if (typeof define == "function" && define.amd) { diff --git a/dist/vuedraggable.min.js b/dist/vuedraggable.min.js index 9ce3094c..38749d2d 100644 --- a/dist/vuedraggable.min.js +++ b/dist/vuedraggable.min.js @@ -1 +1 @@ -"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(){function t(t){function e(t){t.parentElement.removeChild(t)}function n(t,e,n){nr-1?r:i[o];this.list.splice(s,0,n),this.computeIndexes()}},onDragRemove:function(t){if(this.list){n(this.$el,t.item,t.oldIndex);var i=!!t.clone;if(i)return void e(t.clone);var o=this.context.currentIndex;this.list.splice(o,1)}},onDragUpdate:function(t){if(this.list){e(t.item),n(t.from,t.item,t.oldIndex);var i=this.context.currentIndex,r=this.visibleIndexes[t.newIndex];o(this.list,i,r)}},onDragEnd:function(t){this.computeIndexes()}}};return f}if(typeof exports == "object"){var e=require("sortablejs");module.exports=t(e)}else if("function"==typeof define&&define.amd)define(["Sortable"],function(e){return t(e)});else if(window&&window.Vue&&window.Sortable){var n=t(window.Sortable);Vue.component("draggable",n)}}(); \ No newline at end of file +"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(){function t(t){function e(t){t.parentElement.removeChild(t)}function n(t,e,n){nr-1?r:i[o];this.list.splice(s,0,n),this.computeIndexes()}},onDragRemove:function(t){if(this.list){n(this.$el,t.item,t.oldIndex);var i=!!t.clone;if(i)return void e(t.clone);var o=this.context.currentIndex;this.list.splice(o,1)}},onDragUpdate:function(t){if(this.list){e(t.item),n(t.from,t.item,t.oldIndex);var i=this.context.currentIndex,r=this.visibleIndexes[t.newIndex];o(this.list,i,r)}},onDragEnd:function(t){this.computeIndexes()}}};return f}if(typeof exports == "object"){var e=require("sortablejs");module.exports=t(e)}else if("function"==typeof define&&define.amd)define(["Sortable"],function(e){return t(e)});else if(window&&window.Vue&&window.Sortable){var n=t(window.Sortable);Vue.component("draggable",n)}}(); \ No newline at end of file diff --git a/examples/Two_Lists.html b/examples/Two_Lists.html index 14450bff..2449b319 100644 --- a/examples/Two_Lists.html +++ b/examples/Two_Lists.html @@ -12,7 +12,7 @@
-

Vue Dragable For

+

Vue Dragable

List 1 draggable

diff --git a/examples/Two_Lists_Clone.html b/examples/Two_Lists_Clone.html index 41a2bf74..babeff0d 100644 --- a/examples/Two_Lists_Clone.html +++ b/examples/Two_Lists_Clone.html @@ -12,7 +12,7 @@
-

Vue Dragable For

+

Vue Dragable

List 1 v-dragable-for

diff --git a/examples/Two_Lists_Clone_If.html b/examples/Two_Lists_Clone_If.html index 35ace481..1f2aa878 100644 --- a/examples/Two_Lists_Clone_If.html +++ b/examples/Two_Lists_Clone_If.html @@ -12,7 +12,7 @@
-

Vue Dragable For

+

Vue Dragable

List 1 dragable

diff --git a/examples/Two_Lists_If.html b/examples/Two_Lists_If.html index 950aa042..034c3985 100644 --- a/examples/Two_Lists_If.html +++ b/examples/Two_Lists_If.html @@ -12,7 +12,7 @@
-

Vue Dragable For

+

Vue Dragable

List 1 dragable

diff --git a/examples/Two_Lists_NoClone_If.html b/examples/Two_Lists_NoClone_If.html index 39c69c39..48b238eb 100644 --- a/examples/Two_Lists_NoClone_If.html +++ b/examples/Two_Lists_NoClone_If.html @@ -12,7 +12,7 @@
-

Vue Dragable For

+

Vue Dragable

List 1 dragable

diff --git a/examples/Ul_example.html b/examples/Ul_example.html new file mode 100644 index 00000000..2f1c5c82 --- /dev/null +++ b/examples/Ul_example.html @@ -0,0 +1,43 @@ + + + + + + Example ul element + + + + + + + +
+

Vue Dragable

+ +
+

List 1 draggable

+ +
  • + {{element.name}} {{index}} +
  • +
    +
    + +
    +

    List 1 v-for

    +
    +
    {{element.name}}
    +
    +
    + + See basic example + See clone element example + See clone v-if element example +
    + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json index bdabe016..d4c953c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vuedraggable", - "version": "2.1.0", + "version": "2.2.0", "description": "draggable component for vue", "main": "dist/vuedraggable.js", "files": [ diff --git a/src/vuedraggable.js b/src/vuedraggable.js index d558b490..08ec9dcc 100644 --- a/src/vuedraggable.js +++ b/src/vuedraggable.js @@ -59,6 +59,10 @@ clone: { type: Function, default : (original) => { return original;} + }, + element:{ + type: String, + default: 'div' } } @@ -66,7 +70,7 @@ props, render (h) { - return h('div', null, this.$slots.default) + return h(this.element, null, this.$slots.default) }, mounted () {