正在加载视频...

视频加载失败

content wave with CSS scroll animation li { animation: grow both var(--custom-in-out-ease); animation-timeline: view(inline); } @​keyframes grow { 50% { width: var(--desired-size); } } bonus javascript for drag to scroll with inertia ✨

40,219 次观看 • 1 年前 •via X (Twitter)

8 条评论

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈1 年前

yes – you should try to avoid animating properties like "width" 💯 but sometimes you make that trade-off depending on what you're doing (some well-known libs do this a lot of the time 👀) here's the @CodePen 🤙

Christian Esmann 的头像
Christian Esmann2 年前

I just launched an all-in-one template for cross-platform development, based on the stack I use myself everyday. Expo, NextJS, TypeScript, Tailwind, Firebase, AppsFlyer, Authentication, Analytics, In-App Purchases, Stripe and a lot more, setup by default.

Santosh | n0c0de.com 的头像
Santosh | n0c0de.com1 年前

CSS scroll animations are like sprinkles on a cupcake—small but so satisfying when done right.

Craig 的头像
Craig1 年前

Beaut

Tiger Abrodi 的头像
Tiger Abrodi1 年前

Animation has gotten as powerful I swear.

Will Thomson 的头像
Will Thomson1 年前

Lovely implementation jhey. Had the same thought around animating width / height but worth the trade off in the end.

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈1 年前

thanks for sharing yours Will 🙏 totally - much better than trying to work out the scaling equivalent whilst maintaining the gap 💀

Robert Penner 的头像
Robert Penner1 年前

Bless you for the in-out ease. 🙏

相关视频

CSS Tip! 🚥 You can create these trending expanding scroll indicators with scroll-driven animations and flex 🤙 .indicator { animation: grow; animation-range: contain calc(50% - var(--size)...; animation-timeline: var(--card); } @​keyframes grow { 50% { flex: 3; }} What's the trick? Put the indicators in a container using flex layout and set a width larger than the number of indicators 😉 .indicators { aspect-ratio: 7 / 1; display: flex; } Importantly, set no gap 🤏 To mimic the gap set a transparent border on each indicator and set the background using padding-box .indicator { background: linear-gradient(#​fff, #​fff) padding-box; border-radius: 50px; border: 4px solid transparent; } Now for the animation. You want to create a view-timeline for each card that moves across 🤙 li:nth-of-type(1) { view-timeline: --one inline; } li:nth-of-type(2) { view-timeline: --two inline; } Make sure they use the inline axis too! The trick is hoisting these view-timeline so the indicators can use them with timeline-scope 👀 .track { timeline-scope: --one, --two, ...; } All that's left is for you to create the animation piece using some calc with the card size ⚡️ .indicator { --size: calc(var(--card-width) * 0.9); animation: grow both linear; animation-range: contain calc(50% - var(--size)) contain calc(50% + var(--size)); } .indicator:nth-of-type(1) { animation-timeline: --one; } .indicator:nth-of-type(2) { animation-timeline: --two; } @​keyframes grow { 50% { flex: 3; }} And there you have it, responsive scroll indicators using CSS scroll-driven animations 😎 Sprinkle a little JavaScript to make them clickable and scroll the the right card ✨ const shift = (event) => { if (event​.target.tagName === "BUTTON") { const index = [...event.target.parentNode.children].indexOf(event​.target); const item = document.querySelector(`li:nth-of-type(${index + 1})`); item.scrollIntoView({ behavior: "smooth", inline: "center" }); } }; As always, any questions or suggestions, let me know. I've put a JavaScript fallback in to use GSAP in browsers that don't have scroll-driven animations 🫶 CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

575,634 次观看 • 2 年前