Commit dc6f3c7e authored by liujiaxin's avatar liujiaxin

sdf

parent 1f67b77a
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 { import {
Label, Label,
...@@ -41,7 +41,7 @@ export class PlayComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -41,7 +41,7 @@ export class PlayComponent implements OnInit, AfterViewInit, OnDestroy {
onResize(event) { onResize(event) {
this.resetContainerItems(); this.resetContainerItems();
} }
constructor() { constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
this.rightAudio.src = 'assets/right.mp3'; this.rightAudio.src = 'assets/right.mp3';
this.rightAudio.load(); this.rightAudio.load();
this.wrongAudio.src = 'assets/wrong.mp3'; this.wrongAudio.src = 'assets/wrong.mp3';
...@@ -95,7 +95,9 @@ export class PlayComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -95,7 +95,9 @@ export class PlayComponent implements OnInit, AfterViewInit, OnDestroy {
} }
} }
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
this.resetContainerItems(); this.resetContainerItems();
...@@ -105,6 +107,11 @@ export class PlayComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -105,6 +107,11 @@ export class PlayComponent implements OnInit, AfterViewInit, OnDestroy {
}, this.saveKey); }, this.saveKey);
} }
refresh() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
move(el, to_x, to_y, cb?: () => void) { move(el, to_x, to_y, cb?: () => void) {
// el.style.position = 'absolute'; // el.style.position = 'absolute';
const x = parseInt(el.offsetLeft, 10); const x = parseInt(el.offsetLeft, 10);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment