正在加载视频...

视频加载失败

#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,321 次观看 • 1 年前 •via X (Twitter)

11 条评论

Brandon McConnell 的头像
Brandon McConnell1 年前

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 的头像
Adam Argyle1 年前

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

CodeRabbit 的头像
CodeRabbit1 年前

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

John Riordan 的头像
John Riordan1 年前

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 的头像
Adam Argyle1 年前

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

Ryan Leichty 的头像
Ryan Leichty1 年前

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 🏳️‍🌈🏳️‍⚧️☭🌍🌹🕊️🌈🖖 的头像
@[email protected] 🏳️‍🌈🏳️‍⚧️☭🌍🌹🕊️🌈🖖1 年前

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

Adam Argyle 的头像
Adam Argyle1 年前

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 的头像
Daniel Vaughn1 年前

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

Martin Bean 的头像
Martin Bean1 年前

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

Fabrizio Calderan 的头像
Fabrizio Calderan1 年前

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

相关视频