mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Fixed exception in animations when animating a view before it's being displayed
This commit is contained in:
@ -156,19 +156,34 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
case common.Properties.backgroundColor:
|
case common.Properties.backgroundColor:
|
||||||
(<any>animation)._originalValue = animation.target.backgroundColor;
|
(<any>animation)._originalValue = animation.target.backgroundColor;
|
||||||
(<any>animation)._propertyResetCallback = (value) => { animation.target.backgroundColor = value };
|
(<any>animation)._propertyResetCallback = (value) => { animation.target.backgroundColor = value };
|
||||||
|
if (presentationLayer != null) {
|
||||||
originalValue = presentationLayer.backgroundColor;
|
originalValue = presentationLayer.backgroundColor;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
originalValue = nativeView.layer.backgroundColor;
|
||||||
|
}
|
||||||
value = value.CGColor;
|
value = value.CGColor;
|
||||||
break;
|
break;
|
||||||
case common.Properties.opacity:
|
case common.Properties.opacity:
|
||||||
(<any>animation)._originalValue = animation.target.opacity;
|
(<any>animation)._originalValue = animation.target.opacity;
|
||||||
(<any>animation)._propertyResetCallback = (value) => { animation.target.opacity = value };
|
(<any>animation)._propertyResetCallback = (value) => { animation.target.opacity = value };
|
||||||
|
if (presentationLayer != null) {
|
||||||
originalValue = presentationLayer.opacity;
|
originalValue = presentationLayer.opacity;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
originalValue = nativeView.layer.opacity;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case common.Properties.rotate:
|
case common.Properties.rotate:
|
||||||
(<any>animation)._originalValue = animation.target.rotate;
|
(<any>animation)._originalValue = animation.target.rotate;
|
||||||
(<any>animation)._propertyResetCallback = (value) => { animation.target.rotate = value };
|
(<any>animation)._propertyResetCallback = (value) => { animation.target.rotate = value };
|
||||||
propertyNameToAnimate = "transform.rotation";
|
propertyNameToAnimate = "transform.rotation";
|
||||||
|
if (presentationLayer != null) {
|
||||||
originalValue = presentationLayer.valueForKeyPath("transform.rotation");
|
originalValue = presentationLayer.valueForKeyPath("transform.rotation");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
originalValue = nativeView.layer.valueForKeyPath("transform.rotation");
|
||||||
|
}
|
||||||
value = value * Math.PI / 180;
|
value = value * Math.PI / 180;
|
||||||
abs = fabs(originalValue - value);
|
abs = fabs(originalValue - value);
|
||||||
if (abs < 0.001 && originalValue !== tempRotate) {
|
if (abs < 0.001 && originalValue !== tempRotate) {
|
||||||
@ -179,18 +194,33 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
(<any>animation)._originalValue = { x:animation.target.translateX, y:animation.target.translateY };
|
(<any>animation)._originalValue = { x:animation.target.translateX, y:animation.target.translateY };
|
||||||
(<any>animation)._propertyResetCallback = (value) => { animation.target.translateX = value.x; animation.target.translateY = value.y; };
|
(<any>animation)._propertyResetCallback = (value) => { animation.target.translateX = value.x; animation.target.translateY = value.y; };
|
||||||
propertyNameToAnimate = "transform"
|
propertyNameToAnimate = "transform"
|
||||||
|
if (presentationLayer != null) {
|
||||||
originalValue = NSValue.valueWithCATransform3D(presentationLayer.transform);
|
originalValue = NSValue.valueWithCATransform3D(presentationLayer.transform);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
originalValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
|
||||||
|
}
|
||||||
value = NSValue.valueWithCATransform3D(CATransform3DTranslate(nativeView.layer.transform, value.x, value.y, 0));
|
value = NSValue.valueWithCATransform3D(CATransform3DTranslate(nativeView.layer.transform, value.x, value.y, 0));
|
||||||
break;
|
break;
|
||||||
case common.Properties.scale:
|
case common.Properties.scale:
|
||||||
(<any>animation)._originalValue = { x:animation.target.scaleX, y:animation.target.scaleY };
|
(<any>animation)._originalValue = { x:animation.target.scaleX, y:animation.target.scaleY };
|
||||||
(<any>animation)._propertyResetCallback = (value) => { animation.target.scaleX = value.x; animation.target.scaleY = value.y; };
|
(<any>animation)._propertyResetCallback = (value) => { animation.target.scaleX = value.x; animation.target.scaleY = value.y; };
|
||||||
propertyNameToAnimate = "transform"
|
propertyNameToAnimate = "transform"
|
||||||
|
if (presentationLayer != null) {
|
||||||
originalValue = NSValue.valueWithCATransform3D(presentationLayer.transform);
|
originalValue = NSValue.valueWithCATransform3D(presentationLayer.transform);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
originalValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
|
||||||
|
}
|
||||||
value = NSValue.valueWithCATransform3D(CATransform3DScale(nativeView.layer.transform, value.x, value.y, 1));
|
value = NSValue.valueWithCATransform3D(CATransform3DScale(nativeView.layer.transform, value.x, value.y, 1));
|
||||||
break;
|
break;
|
||||||
case _transform:
|
case _transform:
|
||||||
|
if (presentationLayer != null) {
|
||||||
originalValue = NSValue.valueWithCATransform3D(presentationLayer.transform);
|
originalValue = NSValue.valueWithCATransform3D(presentationLayer.transform);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
originalValue = NSValue.valueWithCATransform3D(nativeView.layer.transform);
|
||||||
|
}
|
||||||
(<any>animation)._originalValue = { xs:animation.target.scaleX, ys:animation.target.scaleY,
|
(<any>animation)._originalValue = { xs:animation.target.scaleX, ys:animation.target.scaleY,
|
||||||
xt:animation.target.translateX, yt:animation.target.translateY };
|
xt:animation.target.translateX, yt:animation.target.translateY };
|
||||||
(<any>animation)._propertyResetCallback = (value) => {
|
(<any>animation)._propertyResetCallback = (value) => {
|
||||||
|
Reference in New Issue
Block a user