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

Scroll-driven Animations #439

Closed
1 of 3 tasks
ramiy opened this issue Sep 17, 2023 · 7 comments
Closed
1 of 3 tasks

Scroll-driven Animations #439

ramiy opened this issue Sep 17, 2023 · 7 comments
Labels
focus-area-proposal Focus Area Proposal

Comments

@ramiy
Copy link
Contributor

ramiy commented Sep 17, 2023

Description

These scroll-driven animations are currently supported only on one browser engine. It's an amazing feature that reduces a lot of JS, and I personally would love to use it in production websites when all browsers support this feature.

Specification

https://drafts.csswg.org/scroll-animations/

Open Issues

No response

Tests

https://wpt.fyi/results/scroll-animations

Current Implementations

  • Blink
  • Gecko
  • WebKit

Standards Positions

https://groups.google.com/a/chromium.org/g/blink-dev/c/RDKAi9JPHwY/m/Ee9A5LbBAwAJ
mozilla/standards-positions#347
WebKit/standards-positions#152

Browser bug reports

No response

Developer discussions

No response

Polls & Surveys

No response

Existing Usage

https://chromestatus.com/metrics/css/timeline/popularity/725
https://chromestatus.com/metrics/css/timeline/popularity/726
https://chromestatus.com/metrics/css/timeline/popularity/727
https://chromestatus.com/metrics/css/timeline/popularity/750

https://chromestatus.com/metrics/css/timeline/popularity/665
https://chromestatus.com/metrics/css/timeline/popularity/740
https://chromestatus.com/metrics/css/timeline/popularity/741
https://chromestatus.com/metrics/css/timeline/popularity/742

https://chromestatus.com/metrics/css/timeline/popularity/728
https://chromestatus.com/metrics/css/timeline/popularity/729
https://chromestatus.com/metrics/css/timeline/popularity/730
https://chromestatus.com/metrics/css/timeline/popularity/731

https://chromestatus.com/metrics/css/timeline/popularity/762

Workarounds

No response

Accessibility Impact

No response

Privacy Impact

No response

Other

No response

@ramiy ramiy added the focus-area-proposal Focus Area Proposal label Sep 17, 2023
@BearCooder
Copy link

Some examples:

@thebabydino
Copy link

thebabydino commented Oct 4, 2023

About a dozen more pure CSS examples:

  • scroll-triggered image reveal & zoom - reveal & zoom out of image once its parent figure has been scrolled into view to a certain extent (this was created as a pure CSS version of a JS-heavy demo I came across)
  • header slide effect on scroll - different palette depending on how far we've scrolled
    animated gif, showing how the background and the text color change from left to right as we scroll
  • scroll-triggered animation - scrolling all the way to the end makes an animation start playing, while scrolling a bit back up again pauses it (basically toggles the animation-play-state value depending on whether we've scrolled all the way to the end on not)
  • invert text on scroll - how much of the page is inverted depended on how far we've scrolled
    screenshot showing the page scrolled a bit past half, which inverts a bit more than half from the left
  • flip through animal book on scroll - a remake of a 10+ year old demo I once made and which used many invisible hover triggers to flip through the book (as clever as I thought this was at the time, I now think it's an awful idea, please don't do this, there are better ideas if you want to flip through the book depending on mouse position and not on scroll)
    animated gif showing how scrolling 3D flips through the pages of the animal book
  • char by char reveal on scroll - a remake of something I saw on the Toblerone website, where it was done by wrapping every letter in a div (which I thought was quite awful) and using JS
    animated GIF showing the char by char text reveal on scroll
    screenshot with DevTools open so it's clear every letter is wrapped in an element
  • hue rotate on scroll - selectively desaturating the page background-image and then rotating the hue of what's not desaturated + a few other subtle effects as we scroll (pure CSS, single image source version of this demo); meta demo, "dummy" text explains what's happening there
    animated GIF showing the hue rotate effect as we scroll
  • 3D globe axis tilt on scroll
  • 🐌 shrink - scrolling reveals the text, updates the percentage value and spiral shrinks the image (pure CSS version of this JS-heavy demo)
    animated gif showing how scrolling down makes the image covering the entire page shrinks in a spira/ snail fashion revealing the text underneath, which reads "Our solutions use p% less water", where p% grows from 0% to 97% as we scroll
  • diagonal scroll reveal - no JS version of this demo
    animated GIF showing the diagonal scroll reveal effect

Also on the topic of diagonal scroll, I made this meta demo, whose example text explains what's happening there. This demo uses JS, though that's because of shape-outside being tied to floats and not because of the scroll.
animated gif illustrating the diagonal scroll


There are a lot more scroll-driven demos I coded over the years that could use a pure CSS remake with scroll-driven animations, but I haven't had the time to go through all...

@kizu
Copy link

kizu commented Nov 16, 2023

I did write today a post about which proposals from Interop 2024 I'd want to see go forward the most, and this one was in the first place. And I totally forgot that I wanted to provide here a list of articles I (and others) wrote about scroll-driven animations, which show the number of things they make possible:

My articles:

  1. “Future CSS: Wishes Granted by Scroll-driven Animations”
  2. “Fit-to-Width Text” 
  3. “Position-Driven Styles”
  4. “Scroll-Driven State Transfer”
  5. And a smaller blog post “Scroll-Driven Animations in Stable Chrome”

Articles by others I did save links to (there were more, so only what I have at hand right now):

@jgraham
Copy link
Contributor

jgraham commented Nov 30, 2023

How much do people want the CSS-only parts of scroll timelines vs the JS API (i.e. ScrollTimeline and ViewTimeline)? I haven't looked at all the demos here, but the ones I looked at seem to mostly use just CSS features, suggesting those might be higher priority? The proposal itself currently covers both the CSS and JS parts equally.

@ryantownsend
Copy link

ryantownsend commented Nov 30, 2023

@jgraham personally, being able to remove a widespread class of dependency on (often poorly-optimised) JavaScript and replace it with simple pure CSS is a huge win for the web, so I see the CSS side of scroll timelines as more pressing.

@ydaniv
Copy link

ydaniv commented Nov 30, 2023

@jgraham the Web Animations part of SDA also has a huge part here. Today all these effects are done via JS, so having a JS API as a drop-in replacement is also super important.
For example, to sync non-CSS APIs e.g. canvas and video.
So even if the declarative part probably has a higher demand, the imperative part is still much needed!

@wpt-interop
Copy link

Thank you for proposing Scroll-driven Animations for inclusion in Interop 2024.

We wanted to let you know that this proposal was not selected to be part of Interop this year.

This is because we got many more proposals than we could include in this year's project. Note that individual vendors may nevertheless choose to advance work in this area during the forthcoming year. We would welcome this proposal being resubmitted again next year if necessary.

For an overview of our process, see proposal selection. Thank you again for contributing to Interop 2024!

Posted on behalf of the Interop team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus-area-proposal Focus Area Proposal
Projects
Status: Done
Development

No branches or pull requests

9 participants