Skip to content
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

Query Loop: Add animation when navigating with "enhanced pagination" enabled #54746

Closed

Conversation

DAreRodz
Copy link
Contributor

@DAreRodz DAreRodz commented Sep 22, 2023

What?

This PR adds a subtle animation when visiting different pages of a Query Loop with "enhanced pagination" enabled. It also adds a smooth scroll behavior for the navigation.

When reduced-motion is preferred, the animations and the smooth scroll are turned off automatically.

Will close #54060.

Why?

To make the transition a bit more kansei, as mentioned in #53812 (comment).

How?

For the animations, I had to add a new option to navigate() named beforeRender. It's a callback that runs right before we call Preact's render to update the HTML. The callback can be asynchronous, and this PR uses it to animate the current Post Template block before it's updated.

For the scroll behavior, I'm changing the value of the scroll-behavior CSS property on the document.scrollingElement to smooth right before calling element.focus() and restoring its previous value right after.

Testing Instructions

  1. Go to the site editor.
  2. In the Blog Home template, enable the "enhanced pagination" setting for the Query Loop block.
  3. Ensure you have a Query Pagination block.
  4. Visit the home page.
  5. Click on Older Posts.
  6. Check that the fade-out / fade-in animations occur.
  7. Check that the browser smoothly scrolls to the focused item (the first link).
  8. Go to your OS accessibility settings and enable "reduce motion".
  9. Click on Older Posts.
  10. Check that the fade-out / fade-in animations don't happen this time.
  11. Check that the scroll jumps directly to the focused item (the first link).

Screenshots or screencast

Without reduced-motion With reduced-motion
Screen.Recording.2023-09-25.at.14.10.45.mov
Screen.Recording.2023-09-25.at.14.09.23.mov
@github-actions
Copy link

github-actions bot commented Sep 22, 2023

Size Change: +21.2 kB (+1%)

Total Size: 1.64 MB

Filename Size Change
build/block-directory/index.min.js 7.07 kB +15 B (0%)
build/block-editor/index.min.js 218 kB +252 B (0%)
build/block-editor/style-rtl.css 15.6 kB -2 B (0%)
build/block-editor/style.css 15.6 kB -3 B (0%)
build/block-library/blocks/image/style-rtl.css 1.4 kB -18 B (-1%)
build/block-library/blocks/image/style.css 1.39 kB -18 B (-1%)
build/block-library/blocks/image/view.min.js 1.83 kB +2 B (0%)
build/block-library/blocks/navigation-link/style-rtl.css 103 B -12 B (-10%) 👏
build/block-library/blocks/navigation-link/style.css 103 B -12 B (-10%) 👏
build/block-library/blocks/navigation/style-rtl.css 2.26 kB +13 B (+1%)
build/block-library/blocks/navigation/style.css 2.25 kB +13 B (+1%)
build/block-library/blocks/post-featured-image/style-rtl.css 345 B +23 B (+7%) 🔍
build/block-library/blocks/post-featured-image/style.css 345 B +23 B (+7%) 🔍
build/block-library/blocks/post-template/style-rtl.css 500 B +186 B (+59%) 🆘
build/block-library/blocks/post-template/style.css 499 B +185 B (+59%) 🆘
build/block-library/blocks/query/view.min.js 769 B +160 B (+26%) 🚨
build/block-library/blocks/search/editor-rtl.css 184 B +6 B (+3%)
build/block-library/blocks/search/editor.css 184 B +6 B (+3%)
build/block-library/blocks/search/style-rtl.css 613 B +19 B (+3%)
build/block-library/blocks/search/style.css 613 B +19 B (+3%)
build/block-library/editor-rtl.css 12.2 kB +1 B (0%)
build/block-library/index.min.js 207 kB +349 B (0%)
build/block-library/style-rtl.css 14.2 kB +166 B (+1%)
build/block-library/style.css 14.2 kB +163 B (+1%)
build/blocks/index.min.js 51.5 kB +7 B (0%)
build/commands/index.min.js 15.5 kB +6 B (0%)
build/components/index.min.js 248 kB +1.57 kB (+1%)
build/components/style-rtl.css 11.9 kB +95 B (+1%)
build/components/style.css 11.9 kB +96 B (+1%)
build/compose/index.min.js 12.7 kB +1 B (0%)
build/core-commands/index.min.js 2.72 kB +101 B (+4%)
build/core-data/index.min.js 70.5 kB +58 B (0%)
build/customize-widgets/index.min.js 12 kB +11 B (0%)
build/data/index.min.js 8.78 kB -84 B (-1%)
build/edit-post/index.min.js 35.6 kB -1 B (0%)
build/edit-post/style-rtl.css 7.89 kB -34 B (0%)
build/edit-post/style.css 7.88 kB -34 B (0%)
build/edit-site/index.min.js 203 kB +17.4 kB (+9%) 🔍
build/edit-site/style-rtl.css 14.1 kB +157 B (+1%)
build/edit-site/style.css 14.1 kB +163 B (+1%)
build/edit-widgets/index.min.js 17 kB +18 B (0%)
build/editor/index.min.js 45.9 kB -6 B (0%)
build/element/index.min.js 4.87 kB +1 B (0%)
build/format-library/index.min.js 7.79 kB +36 B (0%)
build/interactivity/index.min.js 11.4 kB +13 B (0%)
build/keyboard-shortcuts/index.min.js 1.76 kB +18 B (+1%)
build/list-reusable-blocks/index.min.js 2.21 kB +11 B (0%)
build/nux/index.min.js 2.01 kB +8 B (0%)
build/patterns/index.min.js 3.57 kB +13 B (0%)
build/plugins/index.min.js 1.81 kB +8 B (0%)
build/preferences/index.min.js 1.26 kB +3 B (0%)
build/react-i18n/index.min.js 631 B +7 B (+1%)
build/reusable-blocks/index.min.js 2.73 kB +9 B (0%)
build/rich-text/index.min.js 10.2 kB +14 B (0%)
build/router/index.min.js 1.79 kB +8 B (0%)
build/server-side-render/index.min.js 1.96 kB +11 B (+1%)
build/viewport/index.min.js 967 B -1 B (0%)
build/widgets/index.min.js 7.18 kB +9 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 964 B
build/annotations/index.min.js 2.71 kB
build/api-fetch/index.min.js 2.29 kB
build/autop/index.min.js 2.11 kB
build/blob/index.min.js 461 B
build/block-directory/style-rtl.css 1.04 kB
build/block-directory/style.css 1.04 kB
build/block-editor/content-rtl.css 4.28 kB
build/block-editor/content.css 4.27 kB
build/block-editor/default-editor-styles-rtl.css 403 B
build/block-editor/default-editor-styles.css 403 B
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 138 B
build/block-library/blocks/audio/theme.css 138 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 587 B
build/block-library/blocks/button/editor.css 587 B
build/block-library/blocks/button/style-rtl.css 633 B
build/block-library/blocks/button/style.css 632 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 421 B
build/block-library/blocks/columns/style.css 421 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 647 B
build/block-library/blocks/cover/editor.css 650 B
build/block-library/blocks/cover/style-rtl.css 1.7 kB
build/block-library/blocks/cover/style.css 1.69 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 98 B
build/block-library/blocks/details/style.css 98 B
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 138 B
build/block-library/blocks/embed/theme.css 138 B
build/block-library/blocks/file/editor-rtl.css 316 B
build/block-library/blocks/file/editor.css 316 B
build/block-library/blocks/file/style-rtl.css 311 B
build/block-library/blocks/file/style.css 312 B
build/block-library/blocks/file/view.min.js 321 B
build/block-library/blocks/footnotes/style-rtl.css 201 B
build/block-library/blocks/footnotes/style.css 199 B
build/block-library/blocks/freeform/editor-rtl.css 2.61 kB
build/block-library/blocks/freeform/editor.css 2.61 kB
build/block-library/blocks/gallery/editor-rtl.css 957 B
build/block-library/blocks/gallery/editor.css 962 B
build/block-library/blocks/gallery/style-rtl.css 1.55 kB
build/block-library/blocks/gallery/style.css 1.55 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 654 B
build/block-library/blocks/group/editor.css 654 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 189 B
build/block-library/blocks/heading/style.css 189 B
build/block-library/blocks/html/editor-rtl.css 340 B
build/block-library/blocks/html/editor.css 341 B
build/block-library/blocks/image/editor-rtl.css 834 B
build/block-library/blocks/image/editor.css 833 B
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 478 B
build/block-library/blocks/latest-posts/style.css 478 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 505 B
build/block-library/blocks/media-text/style.css 503 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 671 B
build/block-library/blocks/navigation-link/editor.css 672 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation/editor-rtl.css 2.26 kB
build/block-library/blocks/navigation/editor.css 2.26 kB
build/block-library/blocks/navigation/view.min.js 1.01 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 401 B
build/block-library/blocks/page-list/editor.css 401 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 235 B
build/block-library/blocks/paragraph/editor.css 235 B
build/block-library/blocks/paragraph/style-rtl.css 335 B
build/block-library/blocks/paragraph/style.css 335 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 508 B
build/block-library/blocks/post-comments-form/style.css 508 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 588 B
build/block-library/blocks/post-featured-image/editor.css 586 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 69 B
build/block-library/blocks/post-time-to-read/style.css 69 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 335 B
build/block-library/blocks/pullquote/style.css 335 B
build/block-library/blocks/pullquote/theme-rtl.css 168 B
build/block-library/blocks/pullquote/theme.css 168 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 486 B
build/block-library/blocks/query/editor.css 486 B
build/block-library/blocks/query/style-rtl.css 375 B
build/block-library/blocks/query/style.css 372 B
build/block-library/blocks/quote/style-rtl.css 222 B
build/block-library/blocks/quote/style.css 222 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 132 B
build/block-library/blocks/read-more/style.css 132 B
build/block-library/blocks/rss/editor-rtl.css 149 B
build/block-library/blocks/rss/editor.css 149 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/search/view.min.js 471 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 234 B
build/block-library/blocks/separator/style.css 234 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 329 B
build/block-library/blocks/shortcode/editor.css 329 B
build/block-library/blocks/site-logo/editor-rtl.css 760 B
build/block-library/blocks/site-logo/editor.css 760 B
build/block-library/blocks/site-logo/style-rtl.css 204 B
build/block-library/blocks/site-logo/style.css 204 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 B
build/block-library/blocks/social-links/editor-rtl.css 682 B
build/block-library/blocks/social-links/editor.css 681 B
build/block-library/blocks/social-links/style-rtl.css 1.45 kB
build/block-library/blocks/social-links/style.css 1.45 kB
build/block-library/blocks/spacer/editor-rtl.css 359 B
build/block-library/blocks/spacer/editor.css 359 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 432 B
build/block-library/blocks/table/editor.css 432 B
build/block-library/blocks/table/style-rtl.css 646 B
build/block-library/blocks/table/style.css 645 B
build/block-library/blocks/table/theme-rtl.css 157 B
build/block-library/blocks/table/theme.css 157 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 403 B
build/block-library/blocks/template-part/editor.css 403 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/term-description/style-rtl.css 111 B
build/block-library/blocks/term-description/style.css 111 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 191 B
build/block-library/blocks/video/style.css 191 B
build/block-library/blocks/video/theme-rtl.css 139 B
build/block-library/blocks/video/theme.css 139 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.11 kB
build/block-library/common.css 1.11 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor.css 12.2 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/theme-rtl.css 700 B
build/block-library/theme.css 705 B
build/block-serialization-default-parser/index.min.js 1.13 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/commands/style-rtl.css 947 B
build/commands/style.css 942 B
build/customize-widgets/style-rtl.css 1.51 kB
build/customize-widgets/style.css 1.5 kB
build/data-controls/index.min.js 651 B
build/date/index.min.js 17.9 kB
build/deprecated/index.min.js 462 B
build/dom-ready/index.min.js 336 B
build/dom/index.min.js 4.68 kB
build/edit-post/classic-rtl.css 571 B
build/edit-post/classic.css 571 B
build/edit-widgets/style-rtl.css 4.84 kB
build/edit-widgets/style.css 4.84 kB
build/editor/style-rtl.css 3.58 kB
build/editor/style.css 3.58 kB
build/escape-html/index.min.js 548 B
build/format-library/style-rtl.css 577 B
build/format-library/style.css 577 B
build/hooks/index.min.js 1.57 kB
build/html-entities/index.min.js 454 B
build/i18n/index.min.js 3.61 kB
build/is-shallow-equal/index.min.js 535 B
build/keycodes/index.min.js 1.9 kB
build/list-reusable-blocks/style-rtl.css 865 B
build/list-reusable-blocks/style.css 865 B
build/media-utils/index.min.js 2.92 kB
build/notices/index.min.js 964 B
build/nux/style-rtl.css 775 B
build/nux/style.css 771 B
build/patterns/style-rtl.css 325 B
build/patterns/style.css 325 B
build/preferences-persistence/index.min.js 1.85 kB
build/primitives/index.min.js 994 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 972 B
build/react-refresh-entry/index.min.js 9.46 kB
build/react-refresh-runtime/index.min.js 6.78 kB
build/redux-routine/index.min.js 2.71 kB
build/reusable-blocks/style-rtl.css 265 B
build/reusable-blocks/style.css 265 B
build/shortcode/index.min.js 1.4 kB
build/style-engine/index.min.js 1.98 kB
build/token-list/index.min.js 587 B
build/url/index.min.js 3.84 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/warning/index.min.js 259 B
build/widgets/style-rtl.css 1.18 kB
build/widgets/style.css 1.18 kB
build/wordcount/index.min.js 1.03 kB

compressed-size-action

@DAreRodz DAreRodz marked this pull request as ready for review September 25, 2023 12:52
@DAreRodz DAreRodz self-assigned this Sep 25, 2023
@DAreRodz DAreRodz added [Type] Enhancement A suggestion for improvement. [Block] Query Loop Affects the Query Loop Block [Feature] Interactivity API API to add frontend interactivity to blocks. labels Sep 25, 2023
@github-actions
Copy link

github-actions bot commented Sep 25, 2023

Flaky tests detected in 40ad702.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6407222363
📝 Reported issues:

@luisherranz
Copy link
Member

I'm not convinced yet about either of these. I think we need to review it more carefully.

@DAreRodz
Copy link
Contributor Author

I'm not convinced yet about either of these. I think we need to review it more carefully.

@luisherranz, what exactly doesn't convince you?

  • a) thebeforeRender API
  • b) the code that shows the animation
  • c) the animation itself
  • d) the code to enable the smooth scrolling
  • e) all of the above

A little more feedback would be great. 😄

PS: I'm turning this back to draft, just in case.

@DAreRodz DAreRodz marked this pull request as draft September 26, 2023 08:45
@luisherranz
Copy link
Member

I'm not convinced about the API (although that's not critical because it's not public), and the animation doesn't feel right. It's not your fault, it's just that I'm not sure whether it adds value to the navigation or not. My inclination is that it doesn't and needs more experimentation. The smooth scroll is nicer, but it doesn't work in Safari and Firefox (although it should?) so that needs more experimentation. In general, it feels a bit rushed to fit all this in today's Beta 1.

@DAreRodz
Copy link
Contributor Author

[...] the animation doesn't feel right.

TBH, I had the same feeling. 🙁 I think it's because the smooth scroll happens simultaneously, so you can barely notice the animation. When there's no scroll, it feels a bit nicer.

The smooth scroll is nicer, but it doesn't work in Safari and Firefox.

That's bad. I wasn't aware, but it looks like Element.focus() doesn't respect the specified scroll-behavior. It works though with Element.scrollIntoView(), but that would force us to replicate the focus() scroll logic programmatically.

@jasmussen
Copy link
Contributor

Thank you for taking a stab at this! I would echo Luis, in a direct comparison between these two, I'd prefer no animation, but I think we can tweak things so it works.

Reading into the term "kansei", I'm sensing that captured in that aesthetic sensibility is a need to think about the fuller flow, not just the particular properties of the animation. In that sense, it is good to think through said flow:

  • You view a queried list
  • You scroll down, past the top of the list, and see pagination
  • You click the pagination, and focus is moved to the top of the list prompting the browser to scroll there.

If that is the fuller flow, to realize a good experience we could potentially look at every step of the way:

  • The time that passes after clicking "next page"
  • The easing in and out of the animation, as well as the duration
  • The amount of "overshooting" of the scroll
  • The type of animation, as well as duration, of items in the queried list
  • Ensure there are never any jarring jumps in height of items. I

Pursuant to what's possible, we might try to string all those properties together in one of two ways:

Slow version

  • When clicking "Older posts", don't immediately start the animation, instead start the query list animation. Spend maybe 0.4s, perhaps longer, by fading out existing posts, then fading in the new ones.
  • If the query list needs to change height, let that height animation happen at the same time as the new items fade in. Always ease both in and out so it feels smooth.
  • Maintain focus on the "Older posts" button at least until the final height of the previous posts in the list is calculated and the animation there is completed. By maintaining focus there for a brief moment, we also enable the use case where you want to rapidly click in succession to go to a much older page, perhaps looking at the URL to see which number you're pacing to.
  • Then start scrolling up. Ease in and out, and scroll slowly so the acceleration doesn't feel jarring or jumpy. Can be a long slow animation, perhaps a whole second or more.

Fast version

If the slow version above ends up feeling annoying, try the same recipe, but speed up every value so it's faster than what's demoed in the video on this PR. Virtually instant, but just considered (as per the recipe), and eased instead.

Hope that helps!

@pablohoneyhoney
Copy link

Nice try. I agree it isn't ideal. I do wonder (and was the intent when mentioned) if it's simply a slight fade in between pagination, no scrolling up.

@DAreRodz
Copy link
Contributor Author

DAreRodz commented Oct 2, 2023

Thanks for the feedback, @jasmussen and @pablohoneyhoney. 🙏

simply a slight fade in between pagination, no scrolling up.

I want to try this first, as it seems simpler to develop. Just to clarify―when you say no scrolling up, you mean disabling the smooth behavior rather than not scrolling at all, is that right?

@Poliuk
Copy link

Poliuk commented Oct 2, 2023

I do wonder (and was the intent when mentioned) if it's simply a slight fade in between pagination, no scrolling up.

I've been discussing it with @luisherranz, and we are afraid that removing the scrolling will break the a11y. In case, I've asked @DAreRodz to do a pair programming session with a designer so they can try different approaches synchronously and hopefully land a solution quickly :)

@jasmussen
Copy link
Contributor

To understand, focus is moved from the "Oldest" to the top of the query block, just like it would if it was a full page refresh. Correct? To that end, I think Pablo's point that the query itself could have a simple fade in, and just immediately jump (no animation on scrolling) depending on the browsers focus behavior.

If I'm not wrong, then in cases where the whole query is visible, there would be no scrolling.

@luisherranz
Copy link
Member

focus is moved from the "Oldest" to the top of the query block, just like it would if it was a full page refresh. Correct?

Yes. Well, it's not exactly as a full page refresh because, as you say, the focus is moved to the first clickable element of the Query block instead of the first clickable element of the page (which is a better experience in terms of accessibility).

So the focus goes from the link you just clicked to the first clickable element of the Query block.

If I'm not wrong, then in cases where the whole query is visible, there would be no scrolling.

Exactly. Scrolling is 100% handled by the browser. Each browser does a slightly different thing, but in general they ensure that the new focused element (the first clickable element of the Query block) is visible.

@DAreRodz
Copy link
Contributor Author

DAreRodz commented Oct 4, 2023

This is the latest feedback I received from @jasmussen:

  • Don't change the scrolling behavior―it's handled by focus― and don't animate it.
  • Add a subtle fade between items in the query loop. I.e. fade out, then fade in items.

Given that, I removed any motion from both the scrolling behavior and the fade-out/in animations. The scroll position changes when the fade-in animation starts, so it feels like the Query Loop items are appearing already in their place.

Also, now that there is no motion at all, I got rid of any code related to reduced-motion support.

I think it's better now. 🙂

Safari Firefox Chrome
Screen.Recording.2023-10-04.at.16.06.19.mov
Screen.Recording.2023-10-04.at.16.04.16.mov
Screen.Recording.2023-10-04.at.16.07.28.mov

cc: @luisherranz @Poliuk

@DAreRodz DAreRodz marked this pull request as ready for review October 4, 2023 14:25
@jasmussen
Copy link
Contributor

Agreed, that is a better experience. In general if an animation doesn't feel right, it's usually best to omit it.

It's a bit frustrating how the three browsers entirely diverge in their handling of focus-scroll, but I'm assuming this is something best left entirely untouched, correct?

What happens to the fade if the next items in the query need to load?

@DAreRodz
Copy link
Contributor Author

DAreRodz commented Oct 5, 2023

What happens to the fade if the next items in the query need to load?

The fade-out animation is triggered when the data is ready before updating the HTML. The new HTML is updated once the fade-out has finished, and the fade-in animation starts right after.

So, in answer to your question, the transition should only be visible once the following items are ready. In the meantime, you can see the loading top bar progressing, so you still have feedback that the browser is waiting for the following items.

@luisherranz
Copy link
Member

After more thinking, I'm opposed to this change.

It doesn't make sense to me to introduce imperative APIs to control the navigate that we would have to maintain indefinitely when it's so clear that the final solution will be declarative and will use the View Transitions API.

So, in my opinion, we should keep investigating how to control the View Transitions API using directives, and how to grant that control to the themes so they can override the block defaults (View Transitions discussion).

@luisherranz luisherranz removed the [Feature] Interactivity API API to add frontend interactivity to blocks. label Oct 12, 2023
@DAreRodz
Copy link
Contributor Author

I'm setting this PR to draft again, as we won't include these changes for now.

@DAreRodz DAreRodz marked this pull request as draft October 16, 2023 09:40
@DAreRodz
Copy link
Contributor Author

DAreRodz commented Mar 18, 2024

Changing the type of the PR to "experimental" and closing it. We can revisit these changes in the future if needed. 🙂

@DAreRodz DAreRodz closed this Mar 18, 2024
@DAreRodz DAreRodz added [Type] Experimental Experimental feature or API. and removed [Type] Enhancement A suggestion for improvement. labels Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Loop Affects the Query Loop Block [Type] Experimental Experimental feature or API.
5 participants