Skip to content

Commit 9f5cc99

Browse files
author
HarshKhandeparkar
committed
feat<RealDrawBoard>:
* option to turn off undos. * turn off undos by default
1 parent 85039b5 commit 9f5cc99

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/constants/defaults/RealDrawBoardDefaults.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const RealDrawBoardDefaults: RealDrawBoardOptions = {
44
brushSize: 1,
55
eraserSize: 2,
66
brushColor: [1, 1, 1],
7-
maxUndos: 15,
7+
allowUndo: false,
8+
maxUndos: 10,
89
mode: 'paint'
910
}

src/renderers/RealDrawBoard/RealDrawBoard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class RealDrawBoard extends RealRenderer {
8888
this.brushColor = options.brushColor;
8989

9090
this.eraserSize = options.eraserSize;
91-
this._maxSnapshots = Math.max(options.maxUndos, 1);
91+
this._maxSnapshots = options.allowUndo ? Math.max(options.maxUndos + 1, 0) : 0;
9292

9393
this.mode = options.mode;
9494
// *****DEFAULTS*****

src/types/RealDrawBoardTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface RealDrawBoardOptions extends RealRendererOptions {
66
brushSize?: number,
77
brushColor?: Color,
88
eraserSize?: number,
9+
allowUndo?: boolean,
910
maxUndos?: number,
1011
mode?: 'paint' | 'erase'
1112
}

0 commit comments

Comments
 (0)