fix: keep the source radius when morphBorderRadius is off - #1
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
TransitionViewzeroed the flying overlay'sborderRadiuswhenevermorphBorderRadiuswasfalse:src/TransitionView.tsx:64seeded the shared value withconfig.morphBorderRadius ? fromRadius : 0src/TransitionView.tsx:107animated it tocfg.morphBorderRadius ? toRadius : 0The cloned child cannot compensate:
styles.contentReset(src/TransitionView.tsx:210) resets the clone's ownborderWidth/borderRadiusbecause the container is meant to draw them. So with morphing off, nothing rounds the corners.Symptom: turn
morphBorderRadiusoff 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
borderRadiusbetween 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,
resolveOverlayRadiusinsrc/overlayRadius.ts, so it is testable:TransitionViewitself imports Reanimated and is unreachable from the Jest setup (noreact-test-renderer, andreact-native-reanimatedis not transformed).Verification
src/__tests__/overlayRadius.test.tscovers both flag states. Counterfactual: with the old? : 0semantics put back into the helper, the two "holds the source radius" cases fail withend: 0, start: 0against55/32, then pass again once restored.yarn test(32 passing),yarn lint, andyarn typecheckare clean.