The demo uses Scroll-Snapping, CSS Reflections (using the proprietary `-webkit-box-reflect`), and Scroll-Linked Animations.
With Scroll-Linked Animations, it’s possible to drive a CSS Animation by scroll: as you scroll, an animation moves forwards/backwards along with it.
In this demo, we track each album cover as they enter and exit the scrollport (enter from the left, exit on the right).
To do this we use a `view-timeline` which can be compared to how IntersectionObserver tracks elements.
```css
li {
view-timeline: li-timeline inline;
}
```
The images themselves are animated using a set of CSS keyframes. We link these keyframes to the ViewTimeline using the `animation-timeline` CSS property.
```css
li img {
animation: rotate-and-show-cover linear forwards;
animation-timeline: li-timeline;
}
```
Scroll-Linked Animations are actively being worked on by our Chrome engineers, and should land later this year / early next year.
It took some time, as the spec underwent a MAJOR rewrite (you might remember prev @scroll-timeline demos from me; that syntax is deprecated)
The folks from Firefox are also working on it, but I don’t know when they are aiming to ship.
To plug any holes, our engineers are also working on a polyfill which is catching up with the latest spec changes. You can already use it, but know it’s in flux. github.com/flackr/scroll-…
There’s much more stuff you can do with it (such as tracking various phases, or tracking a scroller’s progress in general) but that’s food for an upcoming blogpost … or maybe even an #HTTP203 episode 😉
All album covers used in the demo are from the wonderful @LociRecords label their catalogue.
If you’re into downtempo / electronic music, be sure to check them out. Recommended starter album: the “Season Two” compilation.
* Correction, now that I reread this thread: got my sides mixed up in an earlier tweet 🤦♂️
The covers enter the scrollport from the right, and exit it on the left. You can see what’s happening when enabling debug mode. The blue outlines are the <li>s being scrolled in the <ul>
• • •
Missing some Tweet in this thread? You can try to
force a refresh
Now you might be wondering: “What took Chrome so long?!”
Well, if you’ve watched my #HTTP203 episode on Viewports () you know that there currently is a difference between browsers on how they handle the Virtual Keyboard.
Today, some browsers resize the Layout Viewport (and therefore ICB as well), while some don’t.
This difference in ICB resize behavior affects the Viewport Units.
In browsers that support CSS Scroll-Timeline (which is only Chromium with “Experimental Web Platform Features” enabled for now) the effect is achieved using nothing but CSS.
In browsers that don't support CSS Scroll-Timeline a JavaScript polyfill is loaded and used. The animations themselves are regular WAAPI animations, extended with a linked ScrollTimeline instance.
🔥 CSS Features to start learning, as I expect them to ship in all browsers in 2022:
1. Container Queries 2. Cascade Layers 3. Color Functions 4. Viewport Units 5. :has() 6. Overscroll Behaviour 7. Subgrid 8. Accent Color 9. Media Query Ranges
1. Container Queries allow authors to style elements according to the size or appearance of a container. For size-based container queries, this is similar to a @media query, except that it will evaluate against the size of a parent container instead of the viewport.
2. With Cascade Layers, you can control cascade ordering for same-origin rules properly. You do this by layering your styles using the @layer at-rule. Layers appear before specificity and order of appearance in the cascade.
@ChromiumDev In this example you see the API transition between the frame with the avatar and the frame with the info modal. The transition — including "slide up" animation — is handled by the API/browser.