Comparing version 0.0.15 to 0.0.16
{ | ||
"name": "vueboxy", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"description": "A drag and drop solution for arranging components.", | ||
@@ -36,3 +36,3 @@ "author": "David Graham <prograhammer@gmail.com>", | ||
"babel-register": "^6.22.0", | ||
"buefy": "^0.4.6", | ||
"buefy": "^0.5.0", | ||
"chai": "^3.5.0", | ||
@@ -39,0 +39,0 @@ "chalk": "^2.0.1", |
@@ -55,3 +55,2 @@ import touch from './mixins/touch' | ||
this.$emit('beforeDestroy', this.index) | ||
this.destroyListeners() | ||
}, | ||
@@ -58,0 +57,0 @@ |
@@ -148,3 +148,3 @@ import * as Hammer from 'hammerjs' | ||
isEqual (touch) { | ||
return ((touch === this.touchSync) || (touch && this.touchSync && touch.e === this.touchSync.e)) | ||
return ((touch === this.touchSync) || (touch !== null && this.touchSync !== null && touch.e === this.touchSync.e)) | ||
}, | ||
@@ -191,2 +191,4 @@ | ||
updateTouchOffset () { | ||
if (!this.touchSync) return | ||
this.touchSync.offset = this.getTouchOffset(this.touchSync.e) | ||
@@ -197,3 +199,3 @@ }, | ||
this.touchSync = touch | ||
const action = touch ? touch.action : null | ||
const action = touch ? touch.action : '' | ||
@@ -200,0 +202,0 @@ this.updateTouchOffset() |
@@ -44,3 +44,3 @@ import box from './box' | ||
this.initListeners() | ||
this.initBoxes() | ||
this.initBoxes(this.value) | ||
}, | ||
@@ -59,3 +59,3 @@ | ||
value: function (val) { | ||
this.valueWasEmitted ? this.valueWasEmitted = false : this.initBoxes() | ||
this.valueWasEmitted ? this.valueWasEmitted = false : this.initBoxes(val) | ||
}, | ||
@@ -81,2 +81,8 @@ | ||
return this.boxes[this.selectedSync] || null | ||
}, | ||
wasDropped: function () { | ||
return this.selectedBox && this.selectedBox.touch ? this.selectedBox.touch.action === 'drop' : false | ||
}, | ||
wasResized: function () { | ||
return this.selectedBox && this.selectedBox.touch ? this.selectedBox.touch.action === 'resizeEnd' : false | ||
} | ||
@@ -96,2 +102,3 @@ }, | ||
history: [], | ||
historyPointer: -1, | ||
wasSnapped: false, | ||
@@ -122,6 +129,6 @@ selectedSync: this.selected, | ||
initBoxes () { | ||
this.addBoxes() | ||
initBoxes (boxes, pushHistory = true) { | ||
this.addBoxes(boxes) | ||
this.sortBoxes() | ||
this.pushHistory() | ||
if (pushHistory) this.pushHistory() | ||
}, | ||
@@ -141,2 +148,3 @@ | ||
this.sortBoxes() | ||
this.valueWasEmitted = true | ||
this.$emit('input', this.mapValue()) | ||
@@ -164,5 +172,5 @@ eventBus.$emit('wasDraggedOntoCanvas', true) | ||
addBoxes () { | ||
addBoxes (boxes) { | ||
this.boxes = [] | ||
for (const boxData of this.value) { this.addBox(boxData) } | ||
for (const boxData of boxes) { this.addBox(boxData) } | ||
}, | ||
@@ -191,11 +199,35 @@ | ||
pushHistory () { | ||
pushHistory () { // @TODO Refactor complex history functionality. | ||
const mappedValue = this.mapValue() | ||
this.history = [] | ||
this.historyPointer++ | ||
this.history.splice(this.historyPointer) | ||
this.history.push(mappedValue) | ||
this.valueWasEmitted = true | ||
this.$emit('input', mappedValue) | ||
if (this.wasDropped) this.$emit('drop') | ||
if (this.wasResized) this.$emit('resizeEnd') | ||
}, | ||
undo () { | ||
if (!this.historyPointer) return | ||
this.historyPointer-- | ||
this.initBoxes(this.history[this.historyPointer], false) | ||
this.valueWasEmitted = true | ||
this.$emit('input', this.mapValue()) | ||
this.$emit('undo') | ||
}, | ||
redo () { | ||
if (this.historyPointer === this.history.length - 1) return | ||
this.historyPointer++ | ||
this.initBoxes(this.history[this.historyPointer], false) | ||
this.valueWasEmitted = true | ||
this.$emit('input', this.mapValue()) | ||
this.$emit('redo') | ||
}, | ||
mapValue () { | ||
@@ -226,3 +258,5 @@ return this.boxes.map((box) => ({ | ||
restoreBoxFromHistory (box) { | ||
this.$set(box, 'pos', Object.assign({}, this.history[this.history.length - 1][box.index].pos)) | ||
if (this.historyPointer < 0) return | ||
this.$set(box, 'pos', Object.assign({}, this.history[this.historyPointer][box.index].pos)) | ||
}, | ||
@@ -229,0 +263,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
3640309
85
3801