|
|
@@ -21,6 +21,7 @@ export default {
|
|
|
height: document.documentElement.clientHeight,
|
|
|
rects: [],
|
|
|
drawingRect: {},
|
|
|
+ poped: [],
|
|
|
// 为了突破30fps限制(应该与chrome优化机制有关),往数组中多放入冗余数字,以让动画更流畅
|
|
|
overrate: 4
|
|
|
}
|
|
|
@@ -101,7 +102,10 @@ export default {
|
|
|
},
|
|
|
handleMouseUp (e) {
|
|
|
if (!this.noBox) {
|
|
|
- this.drawingRect.begin && this.drawingRect.end && this.rects.push(this.drawingRect)
|
|
|
+ if (this.drawingRect.begin && this.drawingRect.end) {
|
|
|
+ this.rects.push(this.drawingRect)
|
|
|
+ this.poped = []
|
|
|
+ }
|
|
|
this._canvas.removeEventListener('mousemove', this.handleBoxMouseMove)
|
|
|
this.disablePointer = false
|
|
|
this.renderer()
|
|
|
@@ -153,6 +157,20 @@ export default {
|
|
|
},
|
|
|
handleFocus () {
|
|
|
this.$store.commit(USE_FOCUS)
|
|
|
+ },
|
|
|
+ cleanCanvas () {
|
|
|
+ this.rects = []
|
|
|
+ this.renderer()
|
|
|
+ },
|
|
|
+ undo () {
|
|
|
+ const rect = this.rects.pop()
|
|
|
+ rect && this.poped.push(rect)
|
|
|
+ rect && this.renderer()
|
|
|
+ },
|
|
|
+ redo () {
|
|
|
+ const rect = this.poped.pop()
|
|
|
+ rect && this.rects.push(rect)
|
|
|
+ rect && this.renderer()
|
|
|
}
|
|
|
}
|
|
|
}
|