Skip to content

fix: keep the source radius when morphBorderRadius is off - #1

Merged
giaBaoJS merged 1 commit into
mainfrom
fix/hold-source-radius-when-morph-disabled
Sep 1, 2026
Merged

fix: keep the source radius when morphBorderRadius is off#1
giaBaoJS merged 1 commit into
mainfrom
fix/hold-source-radius-when-morph-disabled

Conversation

@giaBaoJS

@giaBaoJS giaBaoJS commented Sep 1, 2026

Copy link
Copy Markdown
Owner

The bug

TransitionView zeroed the flying overlay's borderRadius whenever morphBorderRadius was false:

  • src/TransitionView.tsx:64 seeded the shared value with config.morphBorderRadius ? fromRadius : 0
  • src/TransitionView.tsx:107 animated it to cfg.morphBorderRadius ? toRadius : 0

The cloned child cannot compensate: styles.contentReset (src/TransitionView.tsx:210) resets the clone's own borderWidth/borderRadius because the container is meant to draw them. So with morphing off, nothing rounds the corners.

Symptom: turn morphBorderRadius off on a circular avatar or a rounded card and the element snaps to a hard rectangle the instant the transition starts, stays square for the entire flight, and pops back to round at the hand-off. That is exactly the case where disabling the flag is most attractive, because both endpoints share the same radius and there is nothing to morph.

The flag is documented as "animate borderRadius between the source and target styles" (src/types.ts:73, README.md:129, docs/api.md:59). Off means "do not animate it", not "throw it away".

The fix

The overlay now always starts at the source radius and, when morphing is disabled, ends there too. The resolution moved into a small pure helper, resolveOverlayRadius in src/overlayRadius.ts, so it is testable: TransitionView itself imports Reanimated and is unreachable from the Jest setup (no react-test-renderer, and react-native-reanimated is not transformed).

Verification

src/__tests__/overlayRadius.test.ts covers both flag states. Counterfactual: with the old ? : 0 semantics put back into the helper, the two "holds the source radius" cases fail with end: 0, start: 0 against 55/32, then pass again once restored.

yarn test (32 passing), yarn lint, and yarn typecheck are clean.

Disabling the flag zeroed the overlay's borderRadius instead of leaving it
alone. Because the cloned child's own radius is reset, the container is the
only thing rounding the corners, so a circular avatar flew as a hard square
for the whole transition. Resolve the radius range in a pure helper and hold
the source radius when morphing is disabled.
@giaBaoJS
giaBaoJS merged commit 30960bb into main Sep 1, 2026
5 checks passed
@giaBaoJS
giaBaoJS deleted the fix/hold-source-radius-when-morph-disabled branch September 1, 2026 09:32
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.

1 participant