Skip to content

fix(ios): Prevent animator from animating colors on shadow layer #10686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/core/ui/animation/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,11 @@ export class Animation extends AnimationBase {
this.animateNestedLayerSizeUsingBasicAnimation(nativeView, args.toValue.CGRectValue, animation, args, nativeAnimation);
}

// Shadow layers do not inherit from animating view layer
if (nativeView.outerShadowContainerLayer) {
nativeView.outerShadowContainerLayer.addAnimationForKey(nativeAnimation, args.propertyNameToAnimate);
// Shadow container layer belongs to the parent view layer, so animate all its properties (except for colors) separately
if (args.propertyNameToAnimate && !args.propertyNameToAnimate.endsWith('Color')) {
if (nativeView.outerShadowContainerLayer) {
nativeView.outerShadowContainerLayer.addAnimationForKey(nativeAnimation, args.propertyNameToAnimate);
}
}
}
let callback = undefined;
Expand Down Expand Up @@ -594,7 +596,7 @@ export class Animation extends AnimationBase {
animation._originalValue = nativeView.layer.transform;
nativeView.layer.setValueForKey(args.toValue, args.propertyNameToAnimate);

// Shadow layers do not inherit from animating view layer
// Shadow container layer belongs to the parent view layer, so animate its transform separately
if (nativeView.outerShadowContainerLayer) {
nativeView.outerShadowContainerLayer.setValueForKey(args.toValue, args.propertyNameToAnimate);
}
Expand Down Expand Up @@ -859,7 +861,7 @@ export class Animation extends AnimationBase {
}
}

// Shadow layers do not inherit from animating view layer
// Shadow container layer belongs to the parent view layer, so animate its properties separately
if (nativeView.outerShadowContainerLayer) {
const shadowClipMask = nativeView.outerShadowContainerLayer.mask;

Expand Down
14 changes: 6 additions & 8 deletions packages/core/ui/core/view/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class View extends ViewCommon implements ViewDefinition {
*/
private _modalAnimatedOptions: Array<boolean>;
private _isLaidOut = false;
private _hasTransform = false;
private _isTransformed = false;
private _privateFlags: number = PFLAG_LAYOUT_REQUIRED | PFLAG_FORCE_LAYOUT;
private _cachedFrame: CGRect;
private _suspendCATransaction = false;
Expand All @@ -66,7 +66,7 @@ export class View extends ViewCommon implements ViewDefinition {

this._cachedFrame = null;
this._isLaidOut = false;
this._hasTransform = false;
this._isTransformed = false;
}

public requestLayout(): void {
Expand Down Expand Up @@ -211,7 +211,7 @@ export class View extends ViewCommon implements ViewDefinition {
this._cachedFrame = frame;
let adjustedFrame = null;
let transform = null;
if (this._hasTransform) {
if (this._isTransformed) {
// Always set identity transform before setting frame;
transform = nativeView.layer.transform;
nativeView.layer.transform = CATransform3DIdentity;
Expand All @@ -225,7 +225,7 @@ export class View extends ViewCommon implements ViewDefinition {
nativeView.frame = adjustedFrame;
}

if (this._hasTransform) {
if (this._isTransformed) {
// re-apply the transform after the frame is adjusted
nativeView.layer.transform = transform;
}
Expand Down Expand Up @@ -410,9 +410,7 @@ export class View extends ViewCommon implements ViewDefinition {
transform = iosUtils.applyRotateTransform(transform, this.rotateX, this.rotateY, this.rotate);
transform = CATransform3DScale(transform, scaleX, scaleY, 1);

const needsTransform: boolean = !CATransform3DEqualToTransform(this.nativeViewProtected.layer.transform, transform) || (nativeView.outerShadowContainerLayer && !CATransform3DEqualToTransform(nativeView.outerShadowContainerLayer.transform, transform));

if (needsTransform) {
if (!CATransform3DEqualToTransform(this.nativeViewProtected.layer.transform, transform)) {
const updateSuspended = this._isPresentationLayerUpdateSuspended();
if (!updateSuspended) {
CATransaction.begin();
Expand All @@ -424,7 +422,7 @@ export class View extends ViewCommon implements ViewDefinition {
if (nativeView.outerShadowContainerLayer) {
nativeView.outerShadowContainerLayer.transform = transform;
}
this._hasTransform = this.nativeViewProtected && !CATransform3DEqualToTransform(this.nativeViewProtected.transform3D, CATransform3DIdentity);
this._isTransformed = this.nativeViewProtected && !CATransform3DEqualToTransform(this.nativeViewProtected.transform3D, CATransform3DIdentity);

CATransaction.setDisableActions(false);
if (!updateSuspended) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/ui/styling/background.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ function drawBoxShadow(view: View): void {
}

outerShadowContainerLayer.bounds = bounds;
outerShadowContainerLayer.transform = layer.transform;
outerShadowContainerLayer.anchorPoint = layer.anchorPoint;
outerShadowContainerLayer.position = nativeView.center;
outerShadowContainerLayer.zPosition = layer.zPosition;
Expand Down