Add support for chronological and pagination transitions#2336
Add support for chronological and pagination transitions#2336b1ink0 wants to merge 9 commits intoWordPress:trunkfrom
Conversation
Co-authored-by: Felix Arntz <felixarntz@google.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #2336 +/- ##
==========================================
- Coverage 69.33% 68.92% -0.42%
==========================================
Files 90 90
Lines 7749 7830 +81
==========================================
+ Hits 5373 5397 +24
- Misses 2376 2433 +57
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This might not be necessary. Since admin view transitions have been merged into core, if we do something there it maybe should go into Trac. |
|
@westonruter What do you think about removing the table navigation scope from this PR and handling it in a separate PR instead? It would depend on the implementation of the chronological and pagination transition support that this PR introduces. Since Core currently doesn’t support chronological or pagination transitions, from my perspective it makes sense to first add this functionality to the plugin. Once that’s in place and validated, we can then look at bringing it into Core. |
|
Yes, this PR can be targeted at the frontend only. Any post list table navigation can be considered later, but it seems what is currently in the admin is fine for this. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
Adds support for choosing transition types based on navigation direction/context (chronological and pagination), and exposes new “Chronological and Pagination” options in the plugin’s default transition animation setting.
Changes:
- Introduces JS logic to determine and apply a view-transition “type” (default/chronological/pagination; forwards/backwards) during navigation.
- Extends theme support/config to include additional transition-type-specific animations and attempts to scope CSS to those transition types.
- Adds new settings UI options to enable chronological + pagination transitions for Slide/Swipe/Wipe.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
plugins/view-transitions/js/view-transitions.js |
Adds transition-type detection and assigns the computed type during pageswap/pagereveal. |
plugins/view-transitions/js/types.ts |
Adds a NavigationHistoryEntry type used by the JS transition-type logic. |
plugins/view-transitions/includes/theme.php |
Adds theme support defaults and loads/scopes additional per-type animation CSS and JS config. |
plugins/view-transitions/includes/settings.php |
Adds new “Chronological and Pagination” animation options and maps them to per-type animation settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $additional_animation_args = isset( $theme_support[ $transition_type . '-animation-args' ] ) ? (array) $theme_support[ $transition_type . '-animation-args' ] : array(); | ||
| $additional_animation_stylesheet = $animation_registry->get_animation_stylesheet( $theme_support[ $transition_type . '-animation' ], $additional_animation_args ); | ||
| if ( '' !== $additional_animation_stylesheet ) { | ||
| wp_add_inline_style( | ||
| 'plvt-view-transitions', | ||
| plvt_scope_animation_stylesheet_to_transition_type( $additional_animation_stylesheet, $transition_type ) | ||
| ); |
There was a problem hiding this comment.
The additional transition animation stylesheet is not passed through plvt_inject_animation_duration(), so chronological/pagination animations will ignore the configured default-animation-duration and instead use the CSS file’s default (typically 1s). Apply the same duration injection used for the default animation to each additional transition stylesheet before scoping/adding it.
| if ( isset( $chronological_pagination_animations[ $args['default-animation'] ] ) ) { | ||
| $base_animation = $chronological_pagination_animations[ $args['default-animation'] ]; | ||
| $args['chronological-forwards-animation'] = $base_animation . '-from-right'; | ||
| $args['chronological-backwards-animation'] = $base_animation . '-from-left'; | ||
| $args['pagination-forwards-animation'] = $base_animation . '-from-right'; | ||
| $args['pagination-backwards-animation'] = $base_animation . '-from-left'; | ||
| } |
There was a problem hiding this comment.
When the special *-chronological-pagination option is selected, $args['default-animation'] remains set to that value, but it is not a registered animation slug/alias in the animation registry. As a result, the default transition falls back to the browser default (fade) instead of the intended slide/swipe/wipe. Map $args['default-animation'] to a real registry alias/slug (e.g. the base animation or a concrete direction) when enabling these special options.
| export type NavigationHistoryEntry = { | ||
| url: string; | ||
| }; |
There was a problem hiding this comment.
While adding NavigationHistoryEntry, note that the runtime config.animations now includes values that aren’t represented in the TS types: plvt_load_view_transitions() can emit false for disabled transition types and currently also emits a targetName field. Update ViewTransitionsConfig.animations / ViewTransitionAnimationConfig accordingly (or remove unused fields from the JS config) so the typings match actual data.
| $additional_transition_types = array( | ||
| 'chronological-forwards', | ||
| 'chronological-backwards', | ||
| 'pagination-forwards', | ||
| 'pagination-backwards', | ||
| ); | ||
|
|
There was a problem hiding this comment.
New behavior is introduced for additional transition types (chronological/pagination) and CSS scoping, but the existing PHP unit tests in plugins/view-transitions/tests/test-theme.php don’t cover any of this (e.g. ensuring disabled types remain disabled, and enabled types enqueue scoped CSS). Please add/update tests around the additional transition type handling to prevent regressions.
| foreach ( $additional_transition_types as $transition_type ) { | ||
| if ( isset( $theme_support[ $transition_type . '-animation' ] ) ) { | ||
| $additional_animation_args = isset( $theme_support[ $transition_type . '-animation-args' ] ) ? (array) $theme_support[ $transition_type . '-animation-args' ] : array(); | ||
| $additional_animation_stylesheet = $animation_registry->get_animation_stylesheet( $theme_support[ $transition_type . '-animation' ], $additional_animation_args ); | ||
| if ( '' !== $additional_animation_stylesheet ) { | ||
| wp_add_inline_style( | ||
| 'plvt-view-transitions', | ||
| plvt_scope_animation_stylesheet_to_transition_type( $additional_animation_stylesheet, $transition_type ) | ||
| ); | ||
| } | ||
|
|
||
| $animations_js_config[ $transition_type ] = array( | ||
| 'useGlobalTransitionNames' => $animation_registry->use_animation_global_transition_names( $theme_support[ $transition_type . '-animation' ], $additional_animation_args ), | ||
| 'usePostTransitionNames' => $animation_registry->use_animation_post_transition_names( $theme_support[ $transition_type . '-animation' ], $additional_animation_args ), | ||
| 'targetName' => isset( $additional_animation_args['target-name'] ) ? $additional_animation_args['target-name'] : '*', // Special argument. | ||
| ); | ||
| } else { | ||
| $animations_js_config[ $transition_type ] = false; | ||
| } | ||
| } |
There was a problem hiding this comment.
In the additional transition types loop, isset( $theme_support[ $transition_type . '-animation' ] ) will be true even when the value is false (default), so disabled transition types get treated as enabled and produce a truthy JS config entry. This causes determineTransitionType() to select e.g. chronological-forwards even when the theme support explicitly disables it. Use a truthiness/type check (e.g., non-empty string) rather than isset() and only build $animations_js_config[$transition_type] when an actual animation alias is configured; otherwise set it to false.
|
@b1ink0 I'm not sure if I'm testing this right, but I don't see any difference with this PR versus this branch?
|
|
@westonruter Make sure pretty permalinks are turned on and chronological and pagination transition animation is selected in admin. This branch: Screen.Recording.2026-02-27.at.12.27.09.PM.mov
Screen.Recording.2026-02-27.at.12.28.36.PM.mov |
|
@b1ink0 I guess I'm confused. Shouldn't I be able to leave the default transition animations to fade? I guess I assumed that the Swipe animation would automatically be selected just for the chronological pagination transitions? I'm also not sure exactly what to expect, as I haven't worked much on this plugin or with view transitions generally. |
Currently, my understanding and how the WordPress develop PR version works is that only one animation type can be selected at a time. For example, if fade is selected, it will apply everywhere. Other animations like swipe and slide have different direction types, so if a user selects one of those, they would expect it to work on all pages. With the current implementation of chronological pagination transitions, these are only supported for some animation types, such as slide, wipe, or swipe, since they require an animation type that supports direction. That’s why I thought about adding a new type to the existing types to support this transition.
We can consider this to give users more control. There could be a checkbox to enable chronological pagination transitions, and by default, it could select swipe, which will only apply to chronological pagination–supported pages. All other pages will use the selected normal transition type. Then there could also be a dropdown to select other supported chronological pagination transition types.
I think we should implement this in a way that aligns with user expectations. You can outline what you expect and how it should behave when this is turned on. What do you think about this @westonruter ? |
|
I'll have to study this some more. In the meantime, @mukeshpanchal27 What are your thoughts? |
Summary
Fixes #2318
Relevant technical choices
The implementation of this PR is based on WordPress/wordpress-develop#8370.
Other than that, this PR adds new options to the existing Default Transition Animation setting, allowing users to select chronological and pagination transitions for the supported transition types: Slide, Swipe, and Wipe.
TODO:
View transition between paginated list table navigations in the admin dashboardWill be added in a subsequent PR. This PR will focus on the frontend only for now.