fix(ios): stability around canceling an animation

This commit is contained in:
Nathan Walker
2022-11-23 19:33:18 -08:00
parent a5e3e223dd
commit b8d537250f

View File

@ -222,13 +222,17 @@ export class Animation extends AnimationBase {
return; return;
} }
let i = 0; if (this._mergedPropertyAnimations) {
const length = this._mergedPropertyAnimations.length; for (let i = 0; i < this._mergedPropertyAnimations.length; i++) {
for (; i < length; i++) { const propertyAnimation = this._mergedPropertyAnimations[i];
const propertyAnimation = this._mergedPropertyAnimations[i]; if (propertyAnimation) {
propertyAnimation.target.nativeViewProtected.layer.removeAllAnimations(); if (propertyAnimation.target?.nativeViewProtected?.layer) {
if (propertyAnimation._propertyResetCallback) { propertyAnimation.target.nativeViewProtected.layer.removeAllAnimations();
propertyAnimation._propertyResetCallback(propertyAnimation._originalValue, this._valueSource); }
if (propertyAnimation._propertyResetCallback) {
propertyAnimation._propertyResetCallback(propertyAnimation._originalValue, this._valueSource);
}
}
} }
} }
} }
@ -439,7 +443,7 @@ export class Animation extends AnimationBase {
private static _createNativeAnimation(propertyAnimations: Array<PropertyAnimation>, index: number, playSequentially: boolean, args: AnimationInfo, animation: PropertyAnimation, valueSource: 'animation' | 'keyframe', finishedCallback: (cancelled?: boolean) => void) { private static _createNativeAnimation(propertyAnimations: Array<PropertyAnimation>, index: number, playSequentially: boolean, args: AnimationInfo, animation: PropertyAnimation, valueSource: 'animation' | 'keyframe', finishedCallback: (cancelled?: boolean) => void) {
const nativeView = <UIView>animation.target.nativeViewProtected; const nativeView = <UIView>animation.target.nativeViewProtected;
let nativeAnimation; let nativeAnimation;
if (args.subPropertiesToAnimate) { if (args.subPropertiesToAnimate) {
@ -462,7 +466,6 @@ export class Animation extends AnimationBase {
animationDelegate.nextAnimation = callback; animationDelegate.nextAnimation = callback;
} }
} }
} }
private static _createGroupAnimation(args: AnimationInfo, animation: PropertyAnimation) { private static _createGroupAnimation(args: AnimationInfo, animation: PropertyAnimation) {