vuedraggable
Advanced tools
Comparing version 2.2.0 to 2.3.0
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
(function () { | ||
@@ -34,2 +32,5 @@ "use strict"; | ||
function _computeIndexes(slots, children) { | ||
if (!slots) { | ||
return []; | ||
} | ||
return Array.prototype.map.call(children, function (elt) { | ||
@@ -85,3 +86,14 @@ return computeVmIndex(slots, elt); | ||
data: function data() { | ||
return { | ||
transitionMode: false | ||
}; | ||
}, | ||
render: function render(h) { | ||
if (this.$slots.default.length === 1) { | ||
var child = this.$slots.default[0]; | ||
if (child.componentOptions && child.componentOptions.tag === "transition-group") { | ||
this.transitionMode = true; | ||
} | ||
} | ||
return h(this.element, null, this.$slots.default); | ||
@@ -102,3 +114,3 @@ }, | ||
var options = merge(this.options, optionsAdded); | ||
this._sortable = new Sortable(this.$el, options); | ||
this._sortable = new Sortable(this.rootContainer, options); | ||
this.computeIndexes(); | ||
@@ -114,3 +126,13 @@ }, | ||
computed: { | ||
rootContainer: function rootContainer() { | ||
return this.transitionMode ? this.$el.children[0] : this.$el; | ||
} | ||
}, | ||
methods: { | ||
getChildrenNodes: function getChildrenNodes() { | ||
var rawNodes = this.$slots.default; | ||
return this.transitionMode ? rawNodes[0].child.$slots.default : rawNodes; | ||
}, | ||
computeIndexes: function computeIndexes() { | ||
@@ -120,3 +142,3 @@ var _this3 = this; | ||
this.$nextTick(function () { | ||
_this3.visibleIndexes = _computeIndexes(_this3.$slots.default, _this3.$el.children); | ||
_this3.visibleIndexes = _computeIndexes(_this3.getChildrenNodes(), _this3.rootContainer.children); | ||
}); | ||
@@ -128,3 +150,3 @@ }, | ||
} | ||
var currentIndex = computeVmIndex(this.$slots.default, evt.item); | ||
var currentIndex = computeVmIndex(this.getChildrenNodes(), evt.item); | ||
var element = this.list[currentIndex]; | ||
@@ -154,3 +176,3 @@ this.context = { | ||
} | ||
insertNodeAt(this.$el, evt.item, evt.oldIndex); | ||
insertNodeAt(this.rootContainer, evt.item, evt.oldIndex); | ||
var isCloning = !!evt.clone; | ||
@@ -179,3 +201,2 @@ if (isCloning) { | ||
}; | ||
return draggableComponent; | ||
@@ -182,0 +203,0 @@ } |
{ | ||
"name": "vuedraggable", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "draggable component for vue", | ||
@@ -5,0 +5,0 @@ "main": "dist/vuedraggable.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13766
186