mirror of
				https://github.com/NativeScript/NativeScript.git
				synced 2025-11-04 04:18:52 +08:00 
			
		
		
		
	fix(ios): animation layer resilience (#10060)
This commit is contained in:
		@ -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) {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user