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.
This commit is contained in:
Hristo Deshev
2017-03-21 18:42:09 +02:00
committed by Hristo Deshev
parent b902aeae10
commit b89951845b
2 changed files with 6 additions and 6 deletions

View File

@ -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 (<any>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 ((<any>curve) instanceof android.view.animation.LinearInterpolator) {
return <android.view.animation.Interpolator><any>curve;
} else {
throw new Error(`Invalid animation curve: ${curve}`);
}
}

View File

@ -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);