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
feat(nuxt): controllable view transition #25264
feat(nuxt): controllable view transition #25264
Conversation
Run & review this pull request in StackBlitz Codeflow. |
β Live Preview ready!
|
Code review suggestion Co-authored-by: Julien Huang <julien.h.dev@gmail.com>
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.
good to me ! thank you !
The PR with prefers reduced motion changes has been merged fyi |
Thanks! |
Hello, I faced to an issue related to viewTransition, on android mobile(samsung) if we have a sticky bottom container, the elements/components inside are dissapear and appear on page change. https://stackblitz.com/edit/nuxt-view-transitions-5q9zqa?file=app.vue |
@norbertSG this is not an issue with Nuxt, you can read about it here: https://www.nicchan.me/blog/view-transitions-and-stacking-context/ |
π Linked issue
resolve #25263
β Type of change
π Description
To solve the problem mentioned in the linked issue, this PR adds support for the
viewTransition
property inside PageMeta.Similary how pageTransition works, this can be enabled inside nuxt.config.ts's app property globaly, or on a per-page basis using the
definePageMeta
composable.View transitions can also be enabled/disabled in a middleware using the
to.meta.viewTransition
value (again, similary how pageTransitions work).After this PR theexperimental.viewTransition
property does not by itself enables view-transitions on the pages, but only loads the view-transition plugin inside nuxt. One have to enable view transitions using theapp.viewTransition
property or on a per-page basis.As suggested in the code review below, if
experimental.viewTransition
is set,app.viewTransition
uses its value as default.We are not sure how to conditionaly enable the viewTransition property inside the d.ts files, so that typescript knows that the
PageMeta.viewTransition
is only available when theexperimental.viewTransition
value is set totrue
.Initially, we also added checks for the
prefer-reduced-motion
user setting, so that nuxt would skip the transition if set toreduce
. Later we found this PR which does the same, so we reverted that. If that PR gets merged, then this PR should be updated to allowalways
insidePageMeta.viewTransition
, instead of leaving that inexperimental.viewTransition
, since we use that only as a feature guard.We also tried to add documentation for the changes.
We are not very familiar with testing frameworks and are not sure if this functionality is testable or not. So if tests are needed, we would like to get some help :)
(we checked the breaking change checkbox, but since this is an experimental feature, this might not count as one)
π Checklist