Skip to content

add scoped view transitions to fix gift card navigation#768

Closed
gudnuf wants to merge 1 commit intogift-cards-2from
introduce-scoped-transitions
Closed

add scoped view transitions to fix gift card navigation#768
gudnuf wants to merge 1 commit intogift-cards-2from
introduce-scoped-transitions

Conversation

@gudnuf
Copy link
Copy Markdown
Contributor

@gudnuf gudnuf commented Jan 14, 2026

I made it so our view transitions can now accept a scope which allows us to conditionally apply view transition styles. The reason that we need this is for navigation to/from routes that should not use those view transition styles. Previously, if you navigated from / to /gift-cards then the view transitions styles would be applied and the entire page didn't just slide in like it should. You can see the old behavior in Discord

@gudnuf gudnuf requested a review from jbojcic1 January 14, 2026 00:38
@gudnuf gudnuf self-assigned this Jan 14, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
agicash Ready Ready Preview, Comment Jan 14, 2026 0:38am

@supabase
Copy link
Copy Markdown

supabase Bot commented Jan 14, 2026

This pull request has been ignored for the connected project hrebgkfhjpkbxpztqqke because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@@ -1,8 +1,4 @@
/* Available cards section - fade out/in */
.view-transition-available {
view-transition-name: available-cards;
Copy link
Copy Markdown
Contributor Author

@gudnuf gudnuf Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed these utility classes because in some places we were using them and in others we were setting the viewTransitionName in the style prop. I decided now that we have the dynamically applied styles I liked setting the name directly on the style prop, but we could also only use css classes.

If we only use css classes then useScopedTransitionName would either have to prefix the name passed by the caller with view-transition or the caller would have to pass the full class name like view-transition-available. This just seemed more confusing to me.


/* Transactions section - slide up/down with fade */

/* Slide + fade animations for transactions */
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment seemed unnecessary

//
// Solution: Use requestAnimationFrame to delay hasSettled until after the
// browser has captured its snapshot (next frame).
// ---------------------------------------------------------------------------
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent a bunch of time debugging this and I ended up using Cursor's debug mode with everything that I found and it figured it out pretty quick.

Originally, I just compared the targetScope with the result from getViewTransitionScope. This worked when already in the gift-cards scope and just going back and forth between /gift-cards and /gift-cards/$cardId.

The problem came when I would navigate from / to /gift-cards because transition names were not set on any of the elements that they should have been set on. The behavior I was seeing is that the transition would work as expected when going from / to /gift-cards, but then when I would navigate to /gift-cards/$cardId the individual elements were not animated.


export default function GiftCardDetails({ cardId }: GiftCardDetailsProps) {
const navigate = useNavigate();
const navigate = useNavigateWithViewTransition();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, when testing on the gift-cards-2 branch without changing this to useNavigateWithViewTransition I didn't see the X moving like you said so I changed it here.

I do see the problem without these changes when clicking a discover card. The problem is there either way, so I will see about fixing that by applying transition name styles to the add-gift-card.tsx component

@gudnuf
Copy link
Copy Markdown
Contributor Author

gudnuf commented Jan 14, 2026

closing because I found useViewTransitionState from react-router which works well and is much simpler. I just pushed that change to the main gift-cards-2 PR 8ef72e9

@gudnuf gudnuf closed this Jan 14, 2026
@gudnuf gudnuf deleted the introduce-scoped-transitions branch January 29, 2026 23: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