diff --git a/src/app/play/play.component.ts b/src/app/play/play.component.ts index 9ba7c90bc48c3ed92088a87119f3787ce02a5e1e..31741436e620e072571c6ccdf0659a9a3a3b976f 100644 --- a/src/app/play/play.component.ts +++ b/src/app/play/play.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, ViewChild, OnInit, Input, OnDestroy, HostListener, AfterViewInit } from '@angular/core'; +import { ApplicationRef, ChangeDetectorRef,Component, ElementRef, ViewChild, OnInit, Input, OnDestroy, HostListener, AfterViewInit } from '@angular/core'; import { Label, @@ -50,7 +50,8 @@ export class PlayComponent extends BaseResizeComponent implements OnInit, AfterV cw: number; ch: number; - constructor() { + constructor(private appRef: ApplicationRef, + private changeDetectorRef: ChangeDetectorRef) { super(); } @@ -101,6 +102,9 @@ export class PlayComponent extends BaseResizeComponent implements OnInit, AfterV } this.init(); this.initWithData(); + this.changeDetectorRef.markForCheck(); + this.changeDetectorRef.detectChanges(); + this.refresh(); // @ts-ignore if (window['air']) { // @ts-ignore @@ -278,9 +282,14 @@ export class PlayComponent extends BaseResizeComponent implements OnInit, AfterV // }, 10); this.cw = this.previewContainer.nativeElement.offsetWidth; this.ch = this.previewContainer.nativeElement.offsetHeight; + this.refresh(); }); } - + refresh() { + setTimeout(() => { + this.appRef.tick(); + }, 1); + }