File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
nativescript-angular/animations Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 11import { AnimationPlayer } from "@angular/animations" ;
22import { KeyframeAnimation }
33 from "tns-core-modules/ui/animation/keyframe-animation" ;
4+ import { View , EventData } from "tns-core-modules/ui/core/view" ;
45
56import { Keyframe , createKeyframeAnimation } from "./utils" ;
67import { NgView } from "../element-registry" ;
@@ -55,6 +56,21 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
5556 this . _startSubscriptions = [ ] ;
5657 }
5758
59+ // When this issue https://github.com/NativeScript/NativeScript/issues/7984 is fixes in @nativescript/core
60+ // we can change this fix and apply the one that is recommended in that issue.
61+ if ( this . target . isLoaded ) {
62+ this . playAnimation ( ) ;
63+ } else {
64+ this . target . on ( View . loadedEvent , this . onTargetLoaded . bind ( this ) ) ;
65+ }
66+ }
67+
68+ private onTargetLoaded ( args : EventData ) {
69+ this . target . off ( View . loadedEvent , this . onTargetLoaded ) ;
70+ this . playAnimation ( ) ;
71+ }
72+
73+ private playAnimation ( ) {
5874 this . animation . play ( this . target )
5975 . then ( ( ) => this . onFinish ( ) )
6076 . catch ( ( _e ) => { } ) ;
You can’t perform that action at this time.
0 commit comments