fix(ios): animation layer resilience (#10060)

This commit is contained in:
Andy Winter
2022-11-07 11:46:58 -05:00
committed by GitHub
parent f3a5c16530
commit 6cabcab0d5

View File

@ -439,30 +439,30 @@ 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) {
const nativeView = <UIView>animation.target.nativeViewProtected;
let nativeAnimation;
if (args.subPropertiesToAnimate) {
nativeAnimation = this._createGroupAnimation(args, animation);
} else {
nativeAnimation = this._createBasicAnimation(args, animation);
}
const animationDelegate = AnimationDelegateImpl.initWithFinishedCallback(finishedCallback, animation, valueSource);
nativeAnimation.setValueForKey(animationDelegate, 'delegate');
if (nativeView?.layer) {
let nativeAnimation;
if (args.subPropertiesToAnimate) {
nativeAnimation = this._createGroupAnimation(args, animation);
} else {
nativeAnimation = this._createBasicAnimation(args, animation);
}
const animationDelegate = AnimationDelegateImpl.initWithFinishedCallback(finishedCallback, animation, valueSource);
nativeAnimation.setValueForKey(animationDelegate, 'delegate');
nativeView.layer.addAnimationForKey(nativeAnimation, args.propertyNameToAnimate);
let callback = undefined;
if (index + 1 < propertyAnimations.length) {
callback = Animation._createiOSAnimationFunction(propertyAnimations, index + 1, playSequentially, valueSource, finishedCallback);
if (!playSequentially) {
callback();
} else {
animationDelegate.nextAnimation = callback;
}
}
let callback = undefined;
if (index + 1 < propertyAnimations.length) {
callback = Animation._createiOSAnimationFunction(propertyAnimations, index + 1, playSequentially, valueSource, finishedCallback);
if (!playSequentially) {
callback();
} else {
animationDelegate.nextAnimation = callback;
}
}
}
private static _createGroupAnimation(args: AnimationInfo, animation: PropertyAnimation) {