Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

#CSS feature faceoff: scroll triggered stuck nav (left) vs scroll driven animation nav (right) which do you prefer? try it (use Canary for the scroll-state() support)

12,330 görüntüleme • 1 yıl önce •via X (Twitter)

11 Yorum

Brandon McConnell profil fotoğrafı
Brandon McConnell1 yıl önce

Left, personally I still wish there was an easier way to do something like :stuck but I understand the reasoning behind not doing it In my own codebase, I actually support :stuck in tailwind via a custom `stuck` variant that uses JS IntersectionObserver API behind the scenes 😁

Adam Argyle profil fotoğrafı
Adam Argyle1 yıl önce

scroll-state(stuck: top) is pretty easy But yeah, not a one liner

CodeRabbit profil fotoğrafı
CodeRabbit2 yıl önce

AI-first pull request reviewer with context-aware feedback, line-by-line code suggestions, and real-time chat.

John Riordan profil fotoğrafı
John Riordan1 yıl önce

Like all of the other replies this example is designed for trigger. Driven animations I'd argue are for cases where every individual intermediate frame is equally "correct"/desired. I feel like a lot of the driven examples Ive seen are actually subtly trying to be triggered

Adam Argyle profil fotoğrafı
Adam Argyle1 yıl önce

Agree! but I also see the inverse, a page covered in triggered animations that woulda been better linked

Ryan Leichty profil fotoğrafı
Ryan Leichty1 yıl önce

The in-between state of the scroll driven animation isn’t very pleasant. I would only want background or no background with a transition between states

@css@tech.lgbt 🏳️‍🌈🏳️‍⚧️☭🌍🌹🕊️🌈🖖 profil fotoğrafı
@[email protected] 🏳️‍🌈🏳️‍⚧️☭🌍🌹🕊️🌈🖖1 yıl önce

Couldn't you set the right one to trigger after 1px though?

Adam Argyle profil fotoğrafı
Adam Argyle1 yıl önce

Yep, but sorta.. it could easily make it visible, but it can't simply trigger an interruptible opacity transition. to trigger a transition, you gotta do some tricky work, as it's unnatural to how scroll driven animations work

Daniel Vaughn profil fotoğrafı
Daniel Vaughn1 yıl önce

I prefer right, it feels more obvious what is going on. Left feels too abrupt

Martin Bean profil fotoğrafı
Martin Bean1 yıl önce

Neither. I absolutely hate web pages where things like headers change opacity, or shrink/grow as soon as I start scrolling.

Fabrizio Calderan profil fotoğrafı
Fabrizio Calderan1 yıl önce

I prefer the left one, but I would also change the colors of the login button when the header is white

Benzer Videolar

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