Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

CSS Scroll-Snapping + GSAP ScrollTrigger 🙀 What a lovely combo! I didn't know anything about #css scroll-snapping until studying a recent demo from Julio Rodriguez (linked below). I wanted to build my own simplified version from scratch to understand it better. Notice how the animated list of headers always...

29,409 Aufrufe • vor 1 Jahr •via X (Twitter)

8 Kommentare

Profilbild von Carl 💥 Creative Coding Club
Carl 💥 Creative Coding Clubvor 1 Jahr

Here's my "basic" demo using @greensock's ScrollTrigger with CSS Scroll-Snapping

Profilbild von Carl 💥 Creative Coding Club
Carl 💥 Creative Coding Clubvor 1 Jahr

This is the inspiring, extra-fancy @jh3yy version And you can get in on his newsletter here:

Profilbild von Sam Sen | Web & Digital Design
Sam Sen | Web & Digital Designvor 1 Jahr

@jhey Looks awesome!

Profilbild von crapthings
crapthingsvor 1 Jahr

@jhey cool

Profilbild von Dan Florian
Dan Florianvor 1 Jahr

@jhey Works in safari. That’s a shocker 😮

Profilbild von Armando J. Perez-Carreno
Armando J. Perez-Carrenovor 1 Jahr

@jhey Love the demo

Profilbild von Carl 💥 Creative Coding Club
Carl 💥 Creative Coding Clubvor 1 Jahr

@jhey Thanks!!!

Profilbild von Andy
Andyvor 1 Jahr

@jhey Removing the scroll-snap CSS in html { } and li { } doesn’t change the demo behavior at all. It looks like GSAP does all the lifting.

Ähnliche Videos

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 ʕ•ᴥ•ʔ

232,131 Aufrufe • vor 2 Jahren