-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add direction-aware view transitions to view transitions example repo #5791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughReplaces a static post viewTransition with dynamic logic that uses the router to derive numeric postId indices from from/to locations and selects 'warp' or 'warp-backwards' (or disables transition). Adds corresponding CSS keyframes and a warp-backwards variant. Changes
Sequence DiagramsequenceDiagram
participant User
participant Router
participant PostsLayout
participant CSS
User->>Router: navigate to /posts/:postId
Router->>PostsLayout: provide fromLocation & toLocation
PostsLayout->>PostsLayout: match routes -> extract fromId, toId (numbers)
PostsLayout->>PostsLayout: compare indices
alt toId > fromId
PostsLayout->>CSS: return ['warp']
else toId < fromId
PostsLayout->>CSS: return ['warp-backwards']
else equal/invalid
PostsLayout->>CSS: return false (disable transition)
end
CSS->>User: animate using selected keyframes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
examples/react/view-transitions/src/routes/posts.route.tsx(3 hunks)examples/react/view-transitions/src/styles.css(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
examples/{react,solid}/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep example applications under examples/react/ and examples/solid/
Files:
examples/react/view-transitions/src/styles.cssexamples/react/view-transitions/src/routes/posts.route.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
examples/react/view-transitions/src/routes/posts.route.tsx
**/src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Place file-based routes under src/routes/ directories
Files:
examples/react/view-transitions/src/routes/posts.route.tsx
🧠 Learnings (1)
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR
Repo: TanStack/router PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-23T17:36:12.598Z
Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Applied to files:
examples/react/view-transitions/src/routes/posts.route.tsx
🪛 Biome (2.1.2)
examples/react/view-transitions/src/styles.css
[error] 90-90: expected , but instead found (
Remove (
(parse)
[error] 90-90: expected , but instead found warp-backwards
Remove warp-backwards
(parse)
[error] 90-90: expected , but instead found )
Remove )
(parse)
[error] 90-90: Unexpected unknown pseudo-class active-view-transition-type
See MDN web docs for more details.
(lint/correctness/noUnknownPseudoClass)
[error] 91-91: Unknown type selector is not allowed.
See MDN web docs for more details.
Consider replacing the unknown type selector with valid one.
(lint/correctness/noUnknownTypeSelector)
[error] 95-95: Unknown type selector is not allowed.
See MDN web docs for more details.
Consider replacing the unknown type selector with valid one.
(lint/correctness/noUnknownTypeSelector)
🪛 ESLint
examples/react/view-transitions/src/routes/posts.route.tsx
[error] 1-1: '@tanstack/react-router' imported multiple times.
(import/no-duplicates)
|
@maurer2 can you update the same in the solid example as well? |
|
Oh, just realized there wasn't a solid view-transitions example yet - it's being added here |
Hello, I noticed that the example repo for view transitions doesn’t yet include a page demonstrating direction-aware view transitions, so I added this functionality by modifying the existing posts example.
The post page now compares the old and new
postIdvalues to determine the transition direction. It disables view transitions if the direction can't be determined or if the user navigates to the same page. There’s a bit of manual work involved in extracting the ID from the location. I wasn’t able to get the approach described in main.tsx working, since theTSR_indexvalue only seems to only increase with each navigation, making it unsuitable for determining the transition direction. Perhaps there's an easier way to get the previous ID and next ID from the parsed locations.Cheers
Summary by CodeRabbit