vuedraggable
Advanced tools
Comparing version 2.9.0 to 2.10.0
@@ -30,19 +30,30 @@ 'use strict'; | ||
function _computeIndexes(slots, children) { | ||
return !slots ? [] : Array.prototype.map.call(children, function (elt) { | ||
return computeVmIndex(slots, elt); | ||
if (!slots) { | ||
return []; | ||
} | ||
var elmFromNodes = slots.map(function (elt) { | ||
return elt.elm; | ||
}); | ||
return [].concat(_toConsumableArray(children)).map(function (elt) { | ||
return elmFromNodes.indexOf(elt); | ||
}); | ||
} | ||
function emit(evtName, evtData) { | ||
this.$emit(evtName.toLowerCase(), evtData); | ||
var _this = this; | ||
this.$nextTick(function () { | ||
return _this.$emit(evtName.toLowerCase(), evtData); | ||
}); | ||
} | ||
function delegateAndEmit(evtName) { | ||
var _this = this; | ||
var _this2 = this; | ||
return function (evtData) { | ||
if (_this.realList !== null) { | ||
_this['onDrag' + evtName](evtData); | ||
if (_this2.realList !== null) { | ||
_this2['onDrag' + evtName](evtData); | ||
} | ||
emit.call(_this, evtName, evtData); | ||
emit.call(_this2, evtName, evtData); | ||
}; | ||
@@ -91,3 +102,4 @@ } | ||
return { | ||
transitionMode: false | ||
transitionMode: false, | ||
componentMode: false | ||
}; | ||
@@ -105,15 +117,19 @@ }, | ||
mounted: function mounted() { | ||
var _this2 = this; | ||
var _this3 = this; | ||
this.componentMode = this.element.toLowerCase() !== this.$el.nodeName.toLowerCase(); | ||
if (this.componentMode && this.transitionMode) { | ||
throw new Error('Transition-group inside component is not suppported. Please alter element value or remove transition-group. Current element value: ' + this.element); | ||
} | ||
var optionsAdded = {}; | ||
eventsListened.forEach(function (elt) { | ||
optionsAdded['on' + elt] = delegateAndEmit.call(_this2, elt); | ||
optionsAdded['on' + elt] = delegateAndEmit.call(_this3, elt); | ||
}); | ||
eventsToEmit.forEach(function (elt) { | ||
optionsAdded['on' + elt] = emit.bind(_this2, elt); | ||
optionsAdded['on' + elt] = emit.bind(_this3, elt); | ||
}); | ||
var options = _extends({}, this.options, optionsAdded, { onMove: function onMove(evt) { | ||
return _this2.onDragMove(evt); | ||
return _this3.onDragMove(evt); | ||
} }); | ||
@@ -155,2 +171,5 @@ this._sortable = new Sortable(this.rootContainer, options); | ||
getChildrenNodes: function getChildrenNodes() { | ||
if (this.componentMode) { | ||
return this.$children[0].$slots.default; | ||
} | ||
var rawNodes = this.$slots.default; | ||
@@ -160,6 +179,6 @@ return this.transitionMode ? rawNodes[0].child.$slots.default : rawNodes; | ||
computeIndexes: function computeIndexes() { | ||
var _this3 = this; | ||
var _this4 = this; | ||
this.$nextTick(function () { | ||
_this3.visibleIndexes = _computeIndexes(_this3.getChildrenNodes(), _this3.rootContainer.children); | ||
_this4.visibleIndexes = _computeIndexes(_this4.getChildrenNodes(), _this4.rootContainer.children); | ||
}); | ||
@@ -181,6 +200,6 @@ }, | ||
emitChanges: function emitChanges(evt) { | ||
var _this4 = this; | ||
var _this5 = this; | ||
this.$nextTick(function () { | ||
_this4.$emit('change', evt); | ||
_this5.$emit('change', evt); | ||
}); | ||
@@ -212,4 +231,4 @@ }, | ||
getRelatedContextFromMoveEvent: function getRelatedContextFromMoveEvent(_ref2) { | ||
var to = _ref2.to; | ||
var related = _ref2.related; | ||
var to = _ref2.to, | ||
related = _ref2.related; | ||
@@ -216,0 +235,0 @@ var component = this.getUnderlyingPotencialDraggableComponent(to); |
{ | ||
"name": "vuedraggable", | ||
"version": "2.9.0", | ||
"version": "2.10.0", | ||
"description": "draggable component for vue", | ||
@@ -5,0 +5,0 @@ "main": "dist/vuedraggable.js", |
@@ -131,3 +131,3 @@ <p align="center"><img width="100"src="https://raw.githubusercontent.com/SortableJS/Vue.Draggable/master/logo.png"></p> | ||
Function called on the source component to clone element when clone option is true. The unique argument is the viewModel element to be cloned and the returned value should be its cloned version.<br> | ||
Function called on the source component to clone element when clone option is true. The unique argument is the viewModel element to be cloned and the returned value is its cloned version.<br> | ||
By default vue.draggable reuses the viewModel element, so you have to use this hook if you want to clone or deep clone it. | ||
@@ -222,2 +222,5 @@ | ||
- Example with table: | ||
https://jsfiddle.net/dede89/L54yu3L9/ | ||
### Full demo example | ||
@@ -224,0 +227,0 @@ |
22617
294
262