Skip to content

Commit 108f4c2

Browse files
committed
Inital animations were not played in android, since CSS in android is now applied before the native view is created/assigned
1 parent 4069bce commit 108f4c2

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

tns-core-modules/ui/core/view-base/view-base.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,19 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
608608
}
609609

610610
public initNativeView(): void {
611-
//
611+
// No initNativeView(this)?
612+
if (this._cssState) {
613+
this._cssState.playPendingKeyframeAnimations();
614+
}
612615
}
613616

614617
public resetNativeView(): void {
615618
if (this.nativeView && this.recycleNativeView && isAndroid) {
616619
resetNativeView(this);
617620
}
621+
if (this._cssState) {
622+
this._cancelAllAnimations();
623+
}
618624
}
619625

620626
public _setupUI(context: android.content.Context, atIndex?: number, parentIsLoaded?: boolean) {

tns-core-modules/ui/styling/style-scope.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ if (application.hasLaunched()) {
8686
}
8787

8888
export class CssState {
89+
private _pendingKeyframeAnimations: SelectorCore[];
90+
8991
constructor(private view: ViewBase, private match: SelectorsMatch<ViewBase>) {
9092
}
9193

@@ -103,7 +105,15 @@ export class CssState {
103105
}
104106

105107
matchingSelectors.forEach(s => this.applyDescriptors(s.ruleset));
106-
matchingSelectors.forEach(s => this.playKeyframeAnimations(s.ruleset));
108+
this._pendingKeyframeAnimations = matchingSelectors;
109+
this.playPendingKeyframeAnimations();
110+
}
111+
112+
public playPendingKeyframeAnimations() {
113+
if (this._pendingKeyframeAnimations && this.view.nativeView) {
114+
this._pendingKeyframeAnimations.forEach(s => this.playKeyframeAnimationsFromRuleSet(s.ruleset));
115+
this._pendingKeyframeAnimations = null;
116+
}
107117
}
108118

109119
private applyDescriptors(ruleset: RuleSet): void {
@@ -123,7 +133,7 @@ export class CssState {
123133
});
124134
}
125135

126-
private playKeyframeAnimations(ruleset: RuleSet): void {
136+
private playKeyframeAnimationsFromRuleSet(ruleset: RuleSet): void {
127137
let ruleAnimations: kam.KeyframeAnimationInfo[] = ruleset[animationsSymbol];
128138
if (ruleAnimations) {
129139
ensureKeyframeAnimationModule();

0 commit comments

Comments
 (0)