diff --git a/tns-core-modules/ui/animation/animation.android.ts b/tns-core-modules/ui/animation/animation.android.ts index f122896ad..3237943ab 100644 --- a/tns-core-modules/ui/animation/animation.android.ts +++ b/tns-core-modules/ui/animation/animation.android.ts @@ -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; diff --git a/tns-core-modules/ui/core/properties/properties.d.ts b/tns-core-modules/ui/core/properties/properties.d.ts index 2203721a8..3354f6f71 100644 --- a/tns-core-modules/ui/core/properties/properties.d.ts +++ b/tns-core-modules/ui/core/properties/properties.d.ts @@ -113,7 +113,17 @@ export class CssAnimationProperty { 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; } diff --git a/tns-core-modules/ui/core/properties/properties.ts b/tns-core-modules/ui/core/properties/properties.ts index 17e9bf3c4..8e03d0813 100644 --- a/tns-core-modules/ui/core/properties/properties.ts +++ b/tns-core-modules/ui/core/properties/properties.ts @@ -694,7 +694,7 @@ export class CssAnimationProperty { 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 { } } + 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 { return this.properties[name]; } diff --git a/tns-core-modules/ui/core/view/view-common.ts b/tns-core-modules/ui/core/view/view-common.ts index fc40020c0..8cadf2be2 100644 --- a/tns-core-modules/ui/core/view/view-common.ts +++ b/tns-core-modules/ui/core/view/view-common.ts @@ -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 {