From 8ab838c99914e80237aeac6ae13df0ec6fccaf69 Mon Sep 17 00:00:00 2001 From: Thomas Baum Date: Wed, 9 Sep 2020 18:56:07 +0200 Subject: [PATCH] expose redo/undo state --- .../aia-image-annotator.component.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 */