Skip to content

Commit fb14101

Browse files
update history
1 parent 27dcc93 commit fb14101

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

store.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,20 @@ class Store {
7373
}
7474
endPath(event, position) {
7575
if (this.data.mouseTracker) {
76+
this.data.mouseTracker.path.push(position);
7677
if (this.toolType === POINTER) {
77-
this.processPointEvent(this.data.mouseTracker)
78+
this.addVersion()
7879
} else if(this.data.mouseTracker.class) {
79-
this.data.mouseTracker.path.push(position);
8080
this.addShapeToCanvas(this.data.mouseTracker)
8181
}
8282
this.data.mouseTracker = null;
8383
this.emitChanges()
8484
}
8585
}
8686
addShapeToCanvas(shape) {
87-
this.data.shapes = this.data.shapes.push(shape);
88-
this.data.mouseTracker = null;
89-
this._catHistory();
90-
this.history.push(this.data.shapes);
91-
this.historyIndex = -1;
87+
this.data.shapes = this.data.shapes.push(shape)
88+
this.data.mouseTracker = null
89+
this.addVersion()
9290
}
9391
selectShape(position) {
9492
this.data.shapes = this.data.shapes.map(shape => {
@@ -99,8 +97,10 @@ class Store {
9997
}
10098
})
10199
}
102-
processPointEvent(mouseTracker) {
103-
100+
addVersion(){
101+
this._catHistory();
102+
this.history.push(this.data.shapes);
103+
this.historyIndex = -1;
104104
}
105105

106106
undo() {

0 commit comments

Comments
 (0)