diff --git a/packages/core/ui/animation/index.ios.ts b/packages/core/ui/animation/index.ios.ts index 350de5692..ed5d12d4e 100644 --- a/packages/core/ui/animation/index.ios.ts +++ b/packages/core/ui/animation/index.ios.ts @@ -439,30 +439,30 @@ export class Animation extends AnimationBase { private static _createNativeAnimation(propertyAnimations: Array, index: number, playSequentially: boolean, args: AnimationInfo, animation: PropertyAnimation, valueSource: 'animation' | 'keyframe', finishedCallback: (cancelled?: boolean) => void) { const nativeView = 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) {