From b89951845bb9d33bcb4d8c372de360d54daed635 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Tue, 21 Mar 2017 18:42:09 +0200 Subject: [PATCH] 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. --- tns-core-modules/ui/animation/animation.android.ts | 10 +++++----- tns-core-modules/ui/styling/style-scope.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tns-core-modules/ui/animation/animation.android.ts b/tns-core-modules/ui/animation/animation.android.ts index 06fc4b83a..dc2ce32ea 100644 --- a/tns-core-modules/ui/animation/animation.android.ts +++ b/tns-core-modules/ui/animation/animation.android.ts @@ -35,7 +35,7 @@ propertyKeys[Properties.rotate] = Symbol(keyPrefix + Properties.rotate); propertyKeys[Properties.scale] = Symbol(keyPrefix + Properties.scale); propertyKeys[Properties.translate] = Symbol(keyPrefix + Properties.translate); -export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve | android.view.animation.Interpolator): android.view.animation.Interpolator { +export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve | android.view.animation.Interpolator | android.view.animation.LinearInterpolator): android.view.animation.Interpolator { switch (curve) { case "easeIn": if (traceEnabled()) { @@ -70,11 +70,11 @@ export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve } if (curve instanceof CubicBezierAnimationCurve) { return (android).support.v4.view.animation.PathInterpolatorCompat.create(curve.x1, curve.y1, curve.x2, curve.y2); - } - else if (curve instanceof android.view.animation.Interpolator) { + } else if (curve instanceof android.view.animation.Interpolator) { return curve; - } - else { + } else if ((curve) instanceof android.view.animation.LinearInterpolator) { + return curve; + } else { throw new Error(`Invalid animation curve: ${curve}`); } } diff --git a/tns-core-modules/ui/styling/style-scope.ts b/tns-core-modules/ui/styling/style-scope.ts index 75e31a39f..bd8530dd6 100644 --- a/tns-core-modules/ui/styling/style-scope.ts +++ b/tns-core-modules/ui/styling/style-scope.ts @@ -122,7 +122,7 @@ export class CssState { }); let ruleAnimations: kam.KeyframeAnimationInfo[] = ruleset[animationsSymbol]; - if (ruleAnimations && view.isLoaded && view.nativeView !== undefined) { + if (ruleAnimations) { ensureKeyframeAnimationModule(); for (let animationInfo of ruleAnimations) { let animation = keyframeAnimationModule.KeyframeAnimation.keyframeAnimationFromInfo(animationInfo);