diff --git a/projects/aia-lib/src/lib/components/aia-image-annotator/aia-image-annotator.component.ts b/projects/aia-lib/src/lib/components/aia-image-annotator/aia-image-annotator.component.ts index ff711a4..ee45cc9 100644 --- a/projects/aia-lib/src/lib/components/aia-image-annotator/aia-image-annotator.component.ts +++ b/projects/aia-lib/src/lib/components/aia-image-annotator/aia-image-annotator.component.ts @@ -110,19 +110,23 @@ export class AiaImageAnnotatorComponent implements OnInit, OnChanges { * Undo last action */ public undo() { - if (!this._drawCommands.length) { + if (!this.canUndo) { return; } this._redoCommands.push(this._drawCommands.pop()); this.clearCanvas(); this.drawCommandsOnCanvas(this._drawCommands, this.drawingCtx); } + + public get canUndo() { + return !!this._drawCommands.length + } /** * Redo last undone action if available */ public redo() { - if (!this._redoCommands.length) { + if (!this.canRedo) { return; } this._drawCommands.push(this._redoCommands.pop()); @@ -130,6 +134,10 @@ export class AiaImageAnnotatorComponent implements OnInit, OnChanges { this.drawCommandsOnCanvas(this._drawCommands, this.drawingCtx); } + public get canRedo() { + return !!this._redoCommands.length + } + /** * Clears canvas undo-ably */