Skip to content

fix(ios): rotate loop animation not working on iOS#33

Merged
janicduplessis merged 1 commit intomainfrom
@janic/fix-ios-rotate-loop-gate
Apr 8, 2026
Merged

fix(ios): rotate loop animation not working on iOS#33
janicduplessis merged 1 commit intomainfrom
@janic/fix-ios-rotate-loop-gate

Conversation

@janicduplessis
Copy link
Copy Markdown
Collaborator

Description

The fix in #25 added individual key-path animations for transform sub-properties to correctly handle rotate 0→360° with loop. However, the gate condition (hasInitialTransform) still compared composed CATransform3D matrices. Since cos(2π) = cos(0), the matrices for 0° and 360° are mathematically identical, so hasInitialTransform was always NO and the animation block was never entered.

Solution

Move the raw prop value bitmask computation (changedInitTransform) before the gate and use changedInitTransform != 0 to determine hasInitialTransform. This ensures cases like rotate 0→360 are correctly detected as changes regardless of matrix equivalence.

Test plan

  • Run the example app on iOS simulator
  • Navigate to the Spin demo
  • Verify the view continuously rotates (previously it was static)
  • Verify Android behavior is unchanged

Closes #21

The fix in #25 added individual key-path animations for transform
sub-properties to handle rotate 0→360, but the gate condition
(`hasInitialTransform`) still compared composed CATransform3D matrices.
Since cos(2π) = cos(0), the matrices for 0° and 360° are identical,
so the animation block was never entered.

Move the raw prop value bitmask computation before the gate and use it
to determine `hasInitialTransform`, ensuring rotate 0→360 (and any
other equivalent-matrix cases) are correctly detected as changes.

Closes #21
@janicduplessis janicduplessis merged commit 740bef7 into main Apr 8, 2026
4 checks passed
@janicduplessis janicduplessis deleted the @janic/fix-ios-rotate-loop-gate branch April 8, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite rotate animation around Z axis does not loop as expected

1 participant