Fix CssAnimationProperty default value (#4510)

This commit is contained in:
Hristo Hristov
2017-07-06 09:25:17 +03:00
committed by GitHub
parent 9a34fb9091
commit 974ef9d932
4 changed files with 35 additions and 3 deletions

View File

@ -250,9 +250,11 @@ export class Animation extends AnimationBase {
}
let setLocal = this._valueSource === "animation";
const style = propertyAnimation.target.style;
switch (propertyAnimation.property) {
case Properties.opacity:
opacityProperty._initDefaultNativeValue(style);
originalValue1 = nativeView.getAlpha();
nativeArray = Array.create("float", 1);
nativeArray[0] = propertyAnimation.value;
@ -273,6 +275,8 @@ export class Animation extends AnimationBase {
break;
case Properties.backgroundColor:
backgroundColorProperty._initDefaultNativeValue(style);
ensureArgbEvaluator();
originalValue1 = propertyAnimation.target.backgroundColor;
nativeArray = Array.create(java.lang.Object, 2);
@ -303,6 +307,9 @@ export class Animation extends AnimationBase {
break;
case Properties.translate:
translateXProperty._initDefaultNativeValue(style);
translateYProperty._initDefaultNativeValue(style);
xyObjectAnimators = Array.create(android.animation.Animator, 2);
nativeArray = Array.create("float", 1);
@ -344,6 +351,9 @@ export class Animation extends AnimationBase {
break;
case Properties.scale:
scaleXProperty._initDefaultNativeValue(style);
scaleYProperty._initDefaultNativeValue(style);
xyObjectAnimators = Array.create(android.animation.Animator, 2);
nativeArray = Array.create("float", 1);
@ -385,6 +395,8 @@ export class Animation extends AnimationBase {
break;
case Properties.rotate:
rotateProperty._initDefaultNativeValue(style);
originalValue1 = nativeView.getRotation();
nativeArray = Array.create("float", 1);
nativeArray[0] = propertyAnimation.value;

View File

@ -113,7 +113,17 @@ export class CssAnimationProperty<T extends Style, U> {
public register(cls: { prototype: T }): void;
public isSet(instance: T): boolean;
/**
* @private
*/
public _initDefaultNativeValue(target: T): void;
/**
* @private
*/
public _valueConverter?: (value: string) => any;
/**
* @private
*/
public static _getByCssName(name: string): CssAnimationProperty<any, any>;
}

View File

@ -694,7 +694,7 @@ export class CssAnimationProperty<T extends Style, U> {
this.defaultValue = defaultValue;
const cssValue = Symbol(cssName);
const styleValue = Symbol(propertyName);
const styleValue = Symbol(`local:${propertyName}`);
const keyframeValue = Symbol(keyframeName);
const computedValue = Symbol("computed-value:" + propertyName);
this.key = computedValue;
@ -792,6 +792,16 @@ export class CssAnimationProperty<T extends Style, U> {
}
}
public _initDefaultNativeValue(target: T): void {
const defaultValueKey = this.defaultValueKey;
if (!(defaultValueKey in target)) {
const view = target.view;
const getDefault = this.getDefault;
target[defaultValueKey] = view[getDefault] ? view[getDefault]() : this.defaultValue;
}
}
public static _getByCssName(name: string): CssAnimationProperty<any, any> {
return this.properties[name];
}

View File

@ -738,7 +738,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
}
public _getValue(): never {
throw new Error("The View._setValue is obsolete. There is a new property system.");
throw new Error("The View._getValue is obsolete. There is a new property system.");
}
public _setValue(): never {