"Double Animation" on Safari when View Transitions on
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
Which project does this relate to?
Router
Describe the bug
On safari and browser that have default navigation transitions it clashes with view transitions.
Your Example Website or App
Steps to Reproduce the Bug or Issue
- Have the router set up to do page transitions on navigate
- On a safari browser use swipe to navigate back or forward
- Observe seeing two animation: safari's and the view transition
Expected behavior
I only see the default browser animation and not the view transition (we can't do the other way)
This is relatively easy to fix but I think it should be apart of the router itself
import { createRouter } from "@tanstack/react-router";
import { routeTree } from "./routeTree.gen";
let uaVisualTransitionDetected = false;
function installUANavigationTransitionDetection() {
if (globalThis.document === undefined) return;
navigation.addEventListener("navigate", (event) => {
uaVisualTransitionDetected = Boolean(event.hasUAVisualTransition);
});
}
export const getRouter = () => {
installUANavigationTransitionDetection();
const router = createRouter({
routeTree,
defaultViewTransition: {
types: () => {
if (uaVisualTransitionDetected) {
uaVisualTransitionDetected = false;
return false;
}
return [];
},
},
});
return router;
};
Screenshots or Videos
No response
Platform
- Router / Start Version: 1.159.0
- OS: macOS
- Browser: Safari
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the React view-transitions example at src/routes/__root.tsx and trace createRouter's defaultViewTransition handling alongside the navigate event's hasUAVisualTransition value. Reproduce the swipe navigation behavior in Safari, then verify that browser-provided transitions do not trigger a second router view transition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100