Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

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 görüntüleme • 3 yıl önce •via X (Twitter)

10 Yorum

jhey ▲🐻🎈 profil fotoğrafı
jhey ▲🐻🎈3 yıl önce

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 ✨

Florin Pop 👨🏻‍💻 profil fotoğrafı
Florin Pop 👨🏻‍💻3 yıl önce

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

ishmam profil fotoğrafı
ishmam3 yıl önce

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

Marc Boschma profil fotoğrafı
Marc Boschma3 yıl önce

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

jhey ▲🐻🎈 profil fotoğrafı
jhey ▲🐻🎈3 yıl önce

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

Softserve Digital Development profil fotoğrafı
Softserve Digital Development3 yıl önce

@CodePen @mr_papoutsis

Fajar Siddiq profil fotoğrafı
Fajar Siddiq3 yıl önce

@CodePen this is cool @joshmanders

Artur Bień profil fotoğrafı
Artur Bień3 yıl önce

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

jhey ▲🐻🎈 profil fotoğrafı
jhey ▲🐻🎈3 yıl önce

@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 💯

kehinde.code profil fotoğrafı
kehinde.code3 yıl önce

@CodePen Future is here.

Benzer Videolar

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 görüntüleme • 2 yıl önce