Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

Future CSS Tip! 🔮 You can power micro-interactions with scroll driven animations 😎 Define a range with custom props and hook up to body scroll 📜 .avatar{ animation:shrink; animation-timeline:scroll(root); animation-range:calc(var(--head)*0.9) ...; } CodePen.IO link below! 👇

146,987 Aufrufe • vor 3 Jahren •via X (Twitter)

10 Kommentare

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 3 Jahren

Here's that @CodePen link! 🚀 Remember. Only in Chrome Canary for now 🥲 Some of that calc above is obfuscated. If you have an idea of the size of things in your header, it's not too bad working out when things should start moving ✨

Profilbild von Florin Pop 👨🏻‍💻
Florin Pop 👨🏻‍💻vor 3 Jahren

@CodePen Just wondering… how many projects do you pop out a day? 😆 You’re on fire my friend!

Profilbild von ishmam
ishmamvor 3 Jahren

@CodePen epic! this site’s header button hover effect is pretty cool. in case you ever make a pen for it 🥺

Profilbild von Marc Boschma
Marc Boschmavor 3 Jahren

@CodePen It would be really cool if your avatar turned to face the read as it recedes 🤓

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 3 Jahren

@CodePen What a great idea! Can totally do that too! Thanks Marc 🙏

Profilbild von Softserve Digital Development
Softserve Digital Developmentvor 3 Jahren

@CodePen @mr_papoutsis

Profilbild von Fajar Siddiq
Fajar Siddiqvor 3 Jahren

@CodePen this is cool @joshmanders

Profilbild von Artur Bień
Artur Bieńvor 3 Jahren

@CodePen Its not smooth tho. Kinda jumps in a weird way 🤔

Profilbild von jhey ▲🐻🎈
jhey ▲🐻🎈vor 3 Jahren

@CodePen Yeah, this is one of my current gripes with the API 😕 Smooth scrubbing is basically limited to a trackpad. Using an input device like a mouse is really hard to get smooth. I'll still be reaching for GreenSock in most cases unless things like that are improved 💯

Profilbild von kehinde.code
kehinde.codevor 3 Jahren

@CodePen Future is here.

Ähnliche Videos

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: scroll(). Define the animation-range as when you have scrolled 100px. There's a little more though 🤓 That would "scrub" the width animation. Ideally, you want to trigger that animation. You could animate a custom property with steps() timing and use that to define the width ✨ @​property --scrub { syntax: ' '; inherits: true; initial-value: 0; } body { animation: scrub both steps(1, end); animation-timeline: scroll(); animation-range: 0 100px; } Then transition the --scrub property on the CTA and use it for the width 🤙 .cta { transition: --scrub 0.2s; width: calc(48px + (120px * (1 - (var(--scrub) / 100)))); } Other animations are a matter of preference and timing. For example, you could then make the hand wave, scale down the size, and then slide a gradient across 😉 They have the same structure and technique as the original concept. Waving the hand? 👋 Run it twice, offset the transform-origin. .hand { animation: wave both linear 2; animation-timeline: scroll(); animation-range: 30vh 50vh; transform-origin: 65% 75%; } @​keyframes wave { 50% { rotate: 20deg; } } How's it progressively enhanced? Wrap everything in a @​supports query and a @​media query. If there isn't support, users still get a good experience. It's a floating action button that's circular and already collapsed 🤙 @​supports(animation-timeline: scroll()) { @​media(prefers-reduced-motion: no-preference) {...} } Definitely have a play with the code. Amazing what we're going to be able to do with CSS alone! 🔥 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

177,768 Aufrufe • vor 2 Jahren