mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed: animation chaining is not working when using spring animation
This commit is contained in:
@@ -57,7 +57,6 @@ class AnimationDelegateImpl extends NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
(<any>this._propertyAnimation.target)._resumePresentationLayerUpdates();
|
(<any>this._propertyAnimation.target)._resumePresentationLayerUpdates();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public animationDidStopFinished(anim: CAAnimation, flag: boolean): void {
|
public animationDidStopFinished(anim: CAAnimation, flag: boolean): void {
|
||||||
@@ -76,26 +75,26 @@ class AnimationDelegateImpl extends NSObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public uiview_animationWillStart(animationID: string, context: any): void {
|
// public uiview_animationWillStart(animationID: string, context: any): void {
|
||||||
trace.write("AnimationDelegateImpl.animationWillStart, animationID: " + animationID, trace.categories.Animation);
|
// trace.write("AnimationDelegateImpl.animationWillStart, animationID: " + animationID, trace.categories.Animation);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public uiview_animationDidStop(animationID: string, finished: boolean, context: any): void {
|
// public uiview_animationDidStop(animationID: string, finished: boolean, context: any): void {
|
||||||
trace.write("AnimationDelegateImpl.animationDidStop, animationID: " + animationID + ", finished: " + finished, trace.categories.Animation);
|
// trace.write("AnimationDelegateImpl.animationDidStop, animationID: " + animationID + ", finished: " + finished, trace.categories.Animation);
|
||||||
if (this._finishedCallback) {
|
// if (this._finishedCallback) {
|
||||||
var cancelled = !finished;
|
// var cancelled = !finished;
|
||||||
// This could either be the master finishedCallback or an nextAnimationCallback depending on the playSequentially argument values.
|
// // This could either be the master finishedCallback or an nextAnimationCallback depending on the playSequentially argument values.
|
||||||
this._finishedCallback(cancelled);
|
// this._finishedCallback(cancelled);
|
||||||
}
|
// }
|
||||||
if (!finished) {
|
// if (!finished) {
|
||||||
if ((<any>this._propertyAnimation)._propertyResetCallback) {
|
// if ((<any>this._propertyAnimation)._propertyResetCallback) {
|
||||||
(<any>this._propertyAnimation)._propertyResetCallback((<any>this._propertyAnimation)._originalValue);
|
// (<any>this._propertyAnimation)._propertyResetCallback((<any>this._propertyAnimation)._originalValue);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (finished && this.nextAnimation) {
|
// if (finished && this.nextAnimation) {
|
||||||
this.nextAnimation();
|
// this.nextAnimation();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Animation extends common.Animation implements definition.Animation {
|
export class Animation extends common.Animation implements definition.Animation {
|
||||||
@@ -291,30 +290,21 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
delay = CACurrentMediaTime() + (animation.delay / 1000.0);
|
delay = CACurrentMediaTime() + (animation.delay / 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
var animationDelegate: AnimationDelegateImpl;
|
|
||||||
animationDelegate = AnimationDelegateImpl.initWithFinishedCallback(finishedCallback, animation);
|
|
||||||
|
|
||||||
var callback = undefined;
|
var callback = undefined;
|
||||||
if (index+1 < propertyAnimations.length) {
|
var nextAnimation;
|
||||||
callback = Animation._createiOSAnimationFunction(propertyAnimations, index+1, playSequentially, finishedCallback, that);
|
if (index + 1 < propertyAnimations.length) {
|
||||||
if (!playSequentially) {
|
callback = Animation._createiOSAnimationFunction(propertyAnimations, index + 1, playSequentially, finishedCallback, that);
|
||||||
|
if (!playSequentially) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
animationDelegate.nextAnimation = callback;
|
nextAnimation = callback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UIView.animateWithDurationDelayUsingSpringWithDampingInitialSpringVelocityOptionsAnimationsCompletion(duration, delay, 0.2, 0,
|
UIView.animateWithDurationDelayUsingSpringWithDampingInitialSpringVelocityOptionsAnimationsCompletion(duration, delay, 0.2, 0,
|
||||||
UIViewKeyframeAnimationOptions.UIViewKeyframeAnimationOptionCalculationModeLinear,
|
UIViewKeyframeAnimationOptions.UIViewKeyframeAnimationOptionCalculationModeLinear,
|
||||||
() => {
|
() => {
|
||||||
|
|
||||||
if (animationDelegate) {
|
|
||||||
UIView.setAnimationDelegate(animationDelegate);
|
|
||||||
UIView.setAnimationWillStartSelector("uiview_animationWillStart");
|
|
||||||
UIView.setAnimationDidStopSelector("uiview_animationDidStop");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (animation.iterations !== undefined) {
|
if (animation.iterations !== undefined) {
|
||||||
if (animation.iterations === Number.POSITIVE_INFINITY) {
|
if (animation.iterations === Number.POSITIVE_INFINITY) {
|
||||||
UIView.setAnimationRepeatCount(FLT_MAX);
|
UIView.setAnimationRepeatCount(FLT_MAX);
|
||||||
@@ -335,7 +325,11 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
nativeView.layer.setValueForKey(value, propertyNameToAnimate);
|
nativeView.layer.setValueForKey(value, propertyNameToAnimate);
|
||||||
break;
|
break;
|
||||||
case _transform:
|
case _transform:
|
||||||
|
(<any>animation)._originalValue = nativeView.layer.transform;
|
||||||
nativeView.layer.setValueForKey(value, propertyNameToAnimate);
|
nativeView.layer.setValueForKey(value, propertyNameToAnimate);
|
||||||
|
(<any>animation)._propertyResetCallback = function (value) {
|
||||||
|
nativeView.layer.transform = value;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,6 +346,18 @@ export class Animation extends common.Animation implements definition.Animation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if ((<any>animation)._propertyResetCallback) {
|
||||||
|
(<any>animation)._propertyResetCallback((<any>animation)._originalValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (finishedCallback) {
|
||||||
|
var cancelled = !finished;
|
||||||
|
finishedCallback(cancelled);
|
||||||
|
}
|
||||||
|
if (finished && nextAnimation) {
|
||||||
|
nextAnimation();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user