Loading video...
Video Failed to Load
CSS Tip! 📜 You can use scroll-driven animations to progressively enhance collapsing a floating call to action 🤏 .cta { animation: shrink; animation-timeline: scroll(); animation-range: 0 100px; } @keyframes shrink { to { width: 48px; } } That's the gist of it. Use the body scroll position with animation-timeline:... show more
177,768 views • 2 years ago •via X (Twitter)
10 Comments

Here's that @CodePen link! 🚀 Scroll-driven animations are supported in Chromium browsers ⚡️ Your users should get a decent experience in all! 😎 No JavaScript? it'll run if supported and won't if not 🤙 JavaScript and it's not supported? GSAP 😉

the sheer amount of cool stuff you can do with scroll animations 🤯

This looks cool, but if I were the user it would annoy me so much. As a dev, I'd want to add in something so once the user clicks on it once, it goes away.

Totally agree! 💯 Implemented this one to see how it would work. Inspo is taken from Android apps such as the Gmail client. In that app, the "Compose" button does this behavior. Shrinks and grows on scroll.

Can this be used for things “scrolled into view” natively? Or would you still need JS with the web api…. Which for the life of me can’t remember?

Would love Intercom or more chatbots did this!

@setemiojo Love this CSS tip! Scroll-driven animations can really elevate a web design!

For scroll driven animations can we also use it for relative values? I always see absolut numbers but sometimes I don’t know when the comp is in viewport

Yes totally! 💯 The API for that is view() Check this demo out 👇 The heading is animated based on its position within the viewport using the range keywords entry and cover. The animation-timeline is set to view()

That's cool 🤩
