From 6560b6080a8bb1b2f09957fed443cf13eabed106 Mon Sep 17 00:00:00 2001 From: Alex Lockwood Date: Sat, 11 Mar 2017 14:47:50 -0500 Subject: [PATCH] fix potential crash --- src/app/canvas/canvas.component.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/canvas/canvas.component.ts b/src/app/canvas/canvas.component.ts index d2bdcd4a..fee08df4 100644 --- a/src/app/canvas/canvas.component.ts +++ b/src/app/canvas/canvas.component.ts @@ -56,8 +56,6 @@ export class CanvasComponent implements AfterViewInit, OnDestroy { @ViewChild('renderingCanvas') private renderingCanvasRef: ElementRef; @ViewChildren(CanvasRulerDirective) canvasRulers: QueryList; - // TODO: make use of this variable (i.e. only show labeled points for active path, etc.) - private activePathId: string; private cssContainerWidth = 1; private cssContainerHeight = 1; private vlWidth = DEFAULT_VIEWPORT_SIZE; @@ -72,7 +70,6 @@ export class CanvasComponent implements AfterViewInit, OnDestroy { private currentHover: Hover; private currentHoverSplitPreviewPath: Path; private shouldLabelPoints = false; - private shouldDrawLayer = false; private shouldDisableLayer = false; private readonly subscriptions: Subscription[] = []; @@ -96,7 +93,6 @@ export class CanvasComponent implements AfterViewInit, OnDestroy { this.subscriptions.push( this.layerStateService.getVectorLayerObservable(this.canvasType) .subscribe(vl => { - this.shouldDrawLayer = !!vl && !!this.activePathId; const newWidth = vl ? vl.width : DEFAULT_VIEWPORT_SIZE; const newHeight = vl ? vl.height : DEFAULT_VIEWPORT_SIZE; const didSizeChange = this.vlWidth !== newWidth || this.vlHeight !== newHeight; @@ -146,8 +142,6 @@ export class CanvasComponent implements AfterViewInit, OnDestroy { this.subscriptions.push( this.layerStateService.getActivePathIdObservable(this.canvasType) .subscribe(activePathId => { - this.activePathId = activePathId; - this.shouldDrawLayer = !!this.vectorLayer && !!this.activePathId; interpolatePreview(currentAnimatedFraction); this.draw(); })); @@ -177,8 +171,6 @@ export class CanvasComponent implements AfterViewInit, OnDestroy { this.subscriptions.push( this.layerStateService.getActivePathIdObservable(this.canvasType) .subscribe(activePathId => { - this.activePathId = activePathId; - this.shouldDrawLayer = !!this.vectorLayer && !!this.activePathId; this.draw(); })); this.subscriptions.push( @@ -236,10 +228,18 @@ export class CanvasComponent implements AfterViewInit, OnDestroy { this.subscriptions.forEach(s => s.unsubscribe()); } - get vectorLayer() { + private get vectorLayer() { return this.layerStateService.getVectorLayer(this.canvasType); } + private get activePathId() { + return this.layerStateService.getActivePathId(this.canvasType); + } + + private get shouldDrawLayer() { + return !!this.vectorLayer && !!this.activePathId; + } + private resizeAndDraw() { if (!this.isViewInit) { return;