From dc6f3c7ec926698b6e00d0b2ad6df7d2d7c5df5a Mon Sep 17 00:00:00 2001
From: ljx0517 <ljx0517@gmail.com>
Date: Thu, 13 Aug 2020 00:05:22 +0800
Subject: [PATCH] sdf

---
 src/app/play/play.component.ts | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/app/play/play.component.ts b/src/app/play/play.component.ts
index f40bf6b..8a38e91 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 { ChangeDetectorRef, ApplicationRef, Component, ElementRef, ViewChild, OnInit, Input, OnDestroy, HostListener, AfterViewInit } from '@angular/core';
 
 import {
   Label,
@@ -41,7 +41,7 @@ export class PlayComponent implements OnInit, AfterViewInit, OnDestroy {
   onResize(event) {
     this.resetContainerItems();
   }
-  constructor() {
+  constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
     this.rightAudio.src = 'assets/right.mp3';
     this.rightAudio.load();
     this.wrongAudio.src = 'assets/wrong.mp3';
@@ -95,7 +95,9 @@ export class PlayComponent implements OnInit, AfterViewInit, OnDestroy {
         }
 
       }
-
+      this.changeDetectorRef.markForCheck();
+      this.changeDetectorRef.detectChanges();
+      this.refresh();
       this.resetContainerItems();
 
 
@@ -105,6 +107,11 @@ export class PlayComponent implements OnInit, AfterViewInit, OnDestroy {
     }, this.saveKey);
 
   }
+  refresh() {
+    setTimeout(() => {
+      this.appRef.tick();
+    }, 1);
+  }
   move(el, to_x, to_y, cb?: () => void) {
     // el.style.position = 'absolute';
     const x = parseInt(el.offsetLeft, 10);
-- 
2.21.0