正在加载视频...

视频加载失败

Future CSS Tip! 🔮 You can power list animations like you would using IntersectionObserver with CSS scroll-driven animations and zero JS 🤯 el { animation: show; animation-timeline: view(); animation-range: entry; } keyframes show {0%{translate:0 50%;}} CodePen.IO link below! 👇

433,908 次观看 • 3 年前 •via X (Twitter)

10 条评论

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

Here's that @CodePen link! 🚀 Remember, need to be in Chrome 115+ to see this in action and for the View Transitions to fire 👀 Love trying to combine these new APIs ✨

Simon Ramsay 🚀 🧞‍♂️ 𝕩 的头像
Simon Ramsay 🚀 🧞‍♂️ 𝕩3 年前

@CodePen This is pretty cool. Some strange loading when you click the guitar that you'd need to consider. I guess it's because the elements below haven't loaded because there are out of view...

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

@CodePen Yeah, there's an interesting thing happening here to do with how it works when clicking something that hasn't fully animated into view yet 🤔 Also it depends on where the browser decides it can push the element to when shuffling the grid. Definitely a fun experiment though! 😁

Miguel Correa 的头像
Miguel Correa3 年前

@CodePen Any good resources to learn more about animations that you would recommend? Havent used them much in my career unfortunately

Kevin ⨀ 的头像
Kevin ⨀3 年前

@CodePen can't wait for these features to become the norm

Théo 的头像
Théo3 年前

@CodePen What is this new ? is this vanilla css ?

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

@CodePen It will be soon 🤏 It's only supported in Chrome currently 🥲

Brandon McConnell 的头像
Brandon McConnell3 年前

@CodePen Does this play nicely with lazy loaded images?

jin 的头像
jin3 年前

@CodePen Awesome, I like this. It would be nice to use this feature right away.

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

@CodePen Too right Jin 💯 Will be sweet when it has good support across the board 🤞

相关视频

Future CSS Tip! 🍏 You can create this Apple-style photo scroller by combining CSS scroll-driven animations and CSS scroll-snap 😍 Peep those changing captions 👀 No JS! img { animation: highlight both linear; animation-timeline: view(inline); 👈 Horizontal animation-range: cover 0% cover 50%; 👈 Finish } @ keyframes highlight { 50% { translate: 0 0; scale: var(--starting-scale); 👈 props opacity: var(--starting-opacity); 👈 } 100% { translate: 0 0; scale: 1; opacity: 1; } } Without the animation support, you get a standard unordered list containing some s 🤙 How do we swap the captions though? The "trick" is to use position: absolute on the figcaption and animate their opacity based on the ViewTimeline of their parent list item 😎 figcaption { animation: show both linear; animation-timeline: --list-item; } @ keyframes show { 0%, 45%, 55%, 100% { opacity: 0; } 50% { opacity: 1; } } li { view-timeline-name: --list-item; view-timeline-axis: inline; 👈 important! } The parent of the scroll track uses position: relative so all the captions sit in the middle even though they are in the right place for the markup 🙌 The last bit is the scroll-snap 🤙 Not much to it at all. Wrap the list and make it scrollable. Then add scroll-snap-type .wrapper { scroll-snap-type: x mandatory; overflow-x: scroll; } Then make sure each list item has scroll-snap-align set on it li { scroll-snap-align: center; } That's it! Pretty cool demo to put together and see how to do this stuff with these APIs 🤓 A lot of cool little tricks to pick up for writing your CSS! ⭐️ CodePen.IO link below! 👇

jhey ʕ•ᴥ•ʔ

234,583 次观看 • 2 年前