Skip to content

Commit 5d1b782

Browse files
committed
fix: Added perspective defaults for rotate animation since it makes use of z
1 parent 1a50018 commit 5d1b782

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

packages/core/ui/animation/index.ios.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,13 @@ export class Animation extends AnimationBase {
658658
const x = value[Properties.rotate].x;
659659
const y = value[Properties.rotate].y;
660660
const z = value[Properties.rotate].z;
661+
const perspective = animation.target.perspective || 300;
662+
663+
// Set perspective in case of rotation since we use z
664+
if (x || y) {
665+
result.m34 = -1 / perspective;
666+
}
667+
661668
result = iosHelper.applyRotateTransform(result, x, y, z);
662669
}
663670

@@ -932,11 +939,11 @@ function calculateTransform(view: View): CATransform3D {
932939
// Order is important: translate, rotate, scale
933940
let expectedTransform = new CATransform3D(CATransform3DIdentity);
934941

935-
// Only set perspective if there is 3D rotation
936942
// TODO: Add perspective property to transform animations (not just rotation)
937-
// if (view.rotateX || view.rotateY) {
938-
// expectedTransform.m34 = -1 / perspective;
939-
// }
943+
// Set perspective in case of rotation since we use z
944+
if (view.rotateX || view.rotateY) {
945+
expectedTransform.m34 = -1 / perspective;
946+
}
940947

941948
expectedTransform = CATransform3DTranslate(expectedTransform, view.translateX, view.translateY, 0);
942949
expectedTransform = iosHelper.applyRotateTransform(expectedTransform, view.rotateX, view.rotateY, view.rotate);

0 commit comments

Comments
 (0)