feat(router): add opt-in View Transition support to Link - #5755
Open
rexlunae wants to merge 1 commit into
Open
Conversation
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.
Closes #2658
Adds a
view_transitionprop (defaultfalse, opt-in) to the router'sLinkcomponent. When enabled, clicking the link wraps the navigation in the browser's View Transition API (document.startViewTransition), animating the route change. This is a no-op on browsers/webviews that don't support the API.How it works
The click handler calls
document.startViewTransition(() => {})viadioxus_document::evalbeforerouter.push_any. The old page state is captured synchronously at call time; Dioxus applies the DOM mutations in the microtask checkpoint right after the event handler; the browser captures the new state on the next frame — inside the transition.Notes
dioxus-document's no-op document would only produce an asyncEvalError::Unsupportedthat is never awaited.dioxus-documentdependency is optional and tied to the existinghtmlfeature, matchingdioxus-html.Testing
cargo test -p dioxus-router: all pass (51 tests)cargo clippy -p dioxus-router: cleancargo fmt -p dioxus-router --check: cleandx servesanity check.cc @ealmloff @jkelleyrtp