Skip to content

Commit 9097e48

Browse files
committed
Fix possible race condition
1 parent 13b22bb commit 9097e48

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<canvas></canvas>
1+
<canvas id="canvas" #htmlCanvas></canvas>

projects/angular-editor-fabric-js/src/lib/angular-editor-fabric-js.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
1+
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
22
import { fabric } from 'fabric';
33

44
@Component({
55
selector: 'angular-editor-fabric-js',
6-
templateUrl: 'angular-editor-fabric-js.component.html',
7-
styleUrls: ['angular-editor-fabric-js.component.css'],
6+
templateUrl: './angular-editor-fabric-js.component.html',
7+
styleUrls: ['./angular-editor-fabric-js.component.css'],
88
})
9-
export class FabricjsEditorComponent implements OnInit {
9+
export class FabricjsEditorComponent implements AfterViewInit {
1010
@ViewChild('htmlCanvas') htmlCanvas: ElementRef;
1111

1212
private canvas: fabric.Canvas;
@@ -42,7 +42,7 @@ export class FabricjsEditorComponent implements OnInit {
4242

4343
constructor() { }
4444

45-
ngOnInit() {
45+
ngAfterViewInit(): void {
4646

4747
// setup front side canvas
4848
this.canvas = new fabric.Canvas(this.htmlCanvas.nativeElement, {

0 commit comments

Comments
 (0)