Skip to content

Commit 85039b5

Browse files
author
HarshKhandeparkar
committed
fix<RealDrawBoard>: optimize undo snapshots
1 parent 96eb625 commit 85039b5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/renderers/RealDrawBoard/stroke.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function _startStroke(
55
coords: [number, number],
66
identifier: string
77
) {
8-
if (this._currentSnapshotIndex < this._snapshots.length - 1) this._snapshots.splice(this._currentSnapshotIndex + 1); // Delete all redo snapshots
8+
if (this._currentSnapshotIndex < this._snapshots.length - 1 && this._maxSnapshots > 0) this._snapshots.splice(this._currentSnapshotIndex + 1); // Delete all redo snapshots
99
this._plot(...coords);
1010

1111
this._lastCoords.set(identifier, coords);
@@ -20,7 +20,7 @@ export function _endStroke(
2020

2121
this._lastCoords.delete(identifier);
2222

23-
this._snapshots[++this._currentSnapshotIndex] = this.getData();
23+
if (this._maxSnapshots > 0) this._snapshots[++this._currentSnapshotIndex] = this.getData();
2424
if (this._snapshots.length > this._maxSnapshots) {
2525
this._snapshots.shift();
2626
this._currentSnapshotIndex--;

0 commit comments

Comments
 (0)