Skip to content

Commit b899518

Browse files
committed
Fix CSS animations for elements that have not been loaded yet.
- Always apply animations even if it happens before the loaded event. - Add an extra check for Android LinearInterpolator to get rid of a curve resolution crash.
1 parent b902aea commit b899518

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tns-core-modules/ui/animation/animation.android.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ propertyKeys[Properties.rotate] = Symbol(keyPrefix + Properties.rotate);
3535
propertyKeys[Properties.scale] = Symbol(keyPrefix + Properties.scale);
3636
propertyKeys[Properties.translate] = Symbol(keyPrefix + Properties.translate);
3737

38-
export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve | android.view.animation.Interpolator): android.view.animation.Interpolator {
38+
export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve | android.view.animation.Interpolator | android.view.animation.LinearInterpolator): android.view.animation.Interpolator {
3939
switch (curve) {
4040
case "easeIn":
4141
if (traceEnabled()) {
@@ -70,11 +70,11 @@ export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve
7070
}
7171
if (curve instanceof CubicBezierAnimationCurve) {
7272
return (<any>android).support.v4.view.animation.PathInterpolatorCompat.create(curve.x1, curve.y1, curve.x2, curve.y2);
73-
}
74-
else if (curve instanceof android.view.animation.Interpolator) {
73+
} else if (curve instanceof android.view.animation.Interpolator) {
7574
return curve;
76-
}
77-
else {
75+
} else if ((<any>curve) instanceof android.view.animation.LinearInterpolator) {
76+
return <android.view.animation.Interpolator><any>curve;
77+
} else {
7878
throw new Error(`Invalid animation curve: ${curve}`);
7979
}
8080
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class CssState {
122122
});
123123

124124
let ruleAnimations: kam.KeyframeAnimationInfo[] = ruleset[animationsSymbol];
125-
if (ruleAnimations && view.isLoaded && view.nativeView !== undefined) {
125+
if (ruleAnimations) {
126126
ensureKeyframeAnimationModule();
127127
for (let animationInfo of ruleAnimations) {
128128
let animation = keyframeAnimationModule.KeyframeAnimation.keyframeAnimationFromInfo(animationInfo);

0 commit comments

Comments
 (0)