Загрузка видео...

Не удалось загрузить видео

На главную

browsers mostly skip updating hover state while you scroll so I made super-hover, a tiny utility library that checks what's under your cursor every frame! `pnpm add super-hover`

138,699 просмотров • 4 месяцев назад •via X (Twitter)

Комментарии: 61

Фото профиля daniel petho
daniel petho4 месяцев назад

so why would you use this? well, you probably shouldn't. deprioritizing hover updates is most likely done for performance, so browsers can focus on scrolling, painting and any layout work needed as new elements enter the viewport. which is probably what you want by default!

Фото профиля daniel petho
daniel petho4 месяцев назад

BUT :) updating hover every frame opens up some fun interactions, like this super sick section by Locomotive, which first gave me the idea a while ago:

Фото профиля daniel petho
daniel petho4 месяцев назад

I noticed myself recreating this functionality for the 3rd time for various personal projects and wished this existed, so here it is now

Фото профиля Diego Rodriguez
Diego Rodriguez4 месяцев назад

yo u should check @_chenglou midjourney gallery for an even simpler approach! in particular, the part about non-throttled cursor updates:

Фото профиля daniel petho
daniel petho4 месяцев назад

@_chenglou oh, how many times you showed his site to us haha, and i still missed (or forgot) about this part... thank u!!

Фото профиля Shannon Code
Shannon Code4 месяцев назад

Can we please start shipping prompts already instead of shipping random npm packages?

Фото профиля daniel petho
daniel petho4 месяцев назад

you can def get to this in a few prompts, but at this point it would make more sense to just point the agent to your codebase and describe on which elements you want to achieve an effect like this. so i don’t think it makes too much sense to publish a general prompt but also if you are only worried about installing an npm pkg, you can also point your agent to the codebase on github and say, hey copy this without installing or something code is super short and doesnt have any runtime deps:)

Фото профиля Shannon Code
Shannon Code4 месяцев назад

I just mean in general, and now days it’s almost safer to ship instructions to an agent than an npm package.

Фото профиля DAKOKI
DAKOKI4 месяцев назад

hmm but how bad is it really for performance? Could it be worth it to add a nice touch to prod? Interesting!

Фото профиля daniel petho
daniel petho4 месяцев назад

it is def worse than just using the default `:hover` so I'd say it depends on your use-case: If it's for some fun creative effects, landing pages / portfolios, for sure, but i'd def avoid it for webapps or anywhere where perf is super super important will do some benchmarks later to get a more accurate picture tho

Фото профиля Codedgar
Codedgar4 месяцев назад

This should throttle or have performance considerations no?

Фото профиля daniel petho
daniel petho4 месяцев назад

yes, certainly haha will try to do some benchmarking later to get a more accurate picture how much worse it is tho

Фото профиля Nikil Kuruvilla
Nikil Kuruvilla4 месяцев назад

@AndrewPrifer Interesting I build an npm package called virtual-text-layout that uses pretext alongside Tanstack virtual to do infinite scrolls. I do have a live demo link on the package page.

Фото профиля daniel petho
daniel petho4 месяцев назад

@AndrewPrifer uu this seems interesting, i’ll take a look!

Фото профиля vie ⟢
vie ⟢4 месяцев назад

AWESOME!!!!!!!!

Фото профиля Meefs
Meefs4 месяцев назад

how you gonna show us selected ambient works and have no audio 😭😭

Фото профиля daniel petho
daniel petho4 месяцев назад

🫶

Фото профиля Ankur
Ankur4 месяцев назад

No visible frame drops on react-scan. Thats optimised like crazy. Also im curious is there any other way of doing this? like we can calculate where we are on the container and according to the height of each element we can determine which element is active? @jh3yy

Фото профиля daniel petho
daniel petho4 месяцев назад

1. yeah react-scan can be a good proxy, but it doesn't give a full picture eg. on a more complex site with more elements, where the browser has to do much more work, I'd expect bigger differences between this and native :hover. I'll try to do some proper benchmarking later to get a more accurate picture tho 2. yeah you're right! as @asciidiego also pointed out, this can be achieved much more simply (and prob more performant) if you know your elements' positions/heights/layout etc: I think this library maybe has a place as a drop-in solution where you don't know, or don't want to manage all of that yourself - eg arbitrary tall elements, unknown layouts, framework rendered lists, etc. or idk, maybe I'm just trying to justify the work I did for this in hindsight hahah

Фото профиля Quentin Merabet
Quentin Merabet4 месяцев назад

@AndrewPrifer @devenini + @plcossette coded

Фото профиля daniel petho
daniel petho4 месяцев назад

@AndrewPrifer @devenini @plcossette oh yes!

Фото профиля Quentin Merabet
Quentin Merabet4 месяцев назад

@AndrewPrifer @devenini @plcossette Oh, funny! Didn’t see it!

Фото профиля Nikola Hristov
Nikola Hristov4 месяцев назад

Genius.

Фото профиля Aimeric
Aimeric4 месяцев назад

Heck yeah

Фото профиля CCJoerga
CCJoerga4 месяцев назад

Should have included some benchmarks about the performance.

Фото профиля daniel petho
daniel petho4 месяцев назад

will do!

Фото профиля Brett
Brett4 месяцев назад

So cool

Фото профиля yuwen lu
yuwen lu4 месяцев назад

so good it makes my head spin

Фото профиля rixardo
rixardo4 месяцев назад

can i supply chain attack this

Фото профиля daniel petho
daniel petho4 месяцев назад

the core package has no runtime dependencies, and react/vue are optional peer deps if you use said framework, if that's what you mean. but yeah, otherwise my npm account could be theoretically be compromised like any other account haha

Фото профиля ali
ali4 месяцев назад

lovely

Фото профиля leo san ⭐️ ⊹˚
leo san ⭐️ ⊹˚4 месяцев назад

amazing work, as always! :)

Фото профиля Andy Ramos
Andy Ramos4 месяцев назад

@vaibhav_khulbe It’s the little things 🤌🔥

Фото профиля Leo
Leo4 месяцев назад

You can "hack" the browser's native optimization by making a small CSS animation based on margins, in a loop, and hidden. This way, the browser recalculates the hover on every frame.

Фото профиля daniel petho
daniel petho4 месяцев назад

interesting! do u have an example? or which property to animate?

Фото профиля Leo
Leo4 месяцев назад

I "accidentally" discovered this while building this website. There's a connection between the top marquee and the list. If you remove the marquee, the browser blocks the hover state when scrolling.

Фото профиля RoversX
RoversX4 месяцев назад

Any performance issues?

Фото профиля daniel petho
daniel petho4 месяцев назад

in this demo none, but on a more complex website/lists i'd expect some differences. Will do some benchmarks later!

Фото профиля Filip Wojda
Filip Wojda4 месяцев назад

👌👌

Фото профиля David Sloiko
David Sloiko4 месяцев назад

no. makes me dizzy

Фото профиля daniel petho
daniel petho4 месяцев назад

@sloikodavid i’d say whoever is using this would be responsible to just not use it on reduced-motion enabled. but fair feedback, will include an example about it in the docs, thank you!

Фото профиля Andreas Kruszakin-Liboska
Andreas Kruszakin-Liboska4 месяцев назад

Wow that’s something new! Is the difference really noticeable tho?

Фото профиля daniel petho
daniel petho4 месяцев назад

you mean on terms of performance? in this particular demo there is none, but on a more complex website/list I’d expect some differences

Фото профиля Andreas Kruszakin-Liboska
Andreas Kruszakin-Liboska4 месяцев назад

Yeah that was my question, very cool! Are you planning releasing other frameworks like these for performance optimized animations?

Фото профиля max based
max based4 месяцев назад

dope and on trackpads?

Фото профиля daniel petho
daniel petho4 месяцев назад

trackpads acts like a mouse, so it should work the same unless I misunderstood your question haha

Фото профиля max based
max based4 месяцев назад

oh so it lags behind yeah I wasn't noticing before

Фото профиля timelapse
timelapse4 месяцев назад

Hovers should also be disabled when mouse button is down (during text selection)

Фото профиля daniel petho
daniel petho4 месяцев назад

good catch, will include it, thank u!!

Фото профиля daniel petho
daniel petho4 месяцев назад

for fun! :)

Фото профиля Lokendra
Lokendra4 месяцев назад

Won't degrade the performance?

Фото профиля Tim
Tim4 месяцев назад

What font is used here?

Фото профиля daniel petho
daniel petho4 месяцев назад

fira mono:)

Фото профиля Awnish
Awnish4 месяцев назад

great project!

Фото профиля N!hal
N!hal4 месяцев назад

tuff find

Фото профиля Imtiyaz Ahmed
Imtiyaz Ahmed4 месяцев назад

Omggg! I would loved this months back when I was trying to build my long ass movie tracker. I had similar kind of interaction, didn't work well so skipped it THIS IS GENIUS! Where is my terminal, gotta install it

Фото профиля Ali 🌱
Ali 🌱4 месяцев назад

bro sent the link 😭 really wanna hover this one

Фото профиля Isaac Hinman
Isaac Hinman4 месяцев назад

CPU = 100%

Фото профиля Yassine Zaanouni
Yassine Zaanouni4 месяцев назад

Honestly impressed you noticed this at all, it's the kind of subtle UX 99% of devs scroll right past (pun intended). Bookmarked.

Фото профиля daniel petho
daniel petho4 месяцев назад

haha. but yes I think that also means this is a non-issue:)

Фото профиля Yassine Zaanouni
Yassine Zaanouni4 месяцев назад

These are the kinds of things that make an experience feel premium without the user even knowing why That’s what makes it premium 👌

Похожие видео

CSS variables are live and they are POWERFUL. Now Live on Product Hunt 🚀 ➡️ Create a design system "So you can stay consistent and build much quicker." Define global styles like colors, gradients, sizes, and box shadows. ➡️ Use your variables everywhere "So you never have to manually enter a border color again." You're not limited to just sizes, colors, and font families. Use variables in gradients, box shadows, transforms, and more! ➡️ Start with libraries like Open Props, expertly crafted CSS variables "So you can use a tried and true system, and so we can standardize our Projects." Because there are no abstractions, you can use existing CSS variable libraries like Open Props, an expertly crafted library of CSS variables, and the recommended starting point in Webstudio. ➡️ Create complex micro-interactions "So when you hover a link, you can change any children's styles." CSS variables go beyond reusability! You can define variables anywhere in the navigator, such as on a link, and modify the variables on hover. Then, you can use those variables on the children to create complex micro-interactions! ➡️ Design and build simultaneously "So when deciding that perfect border color, you can arrow through all your options." Experimenting on the canvas just got a whole lot better. Now, you can arrow through your variables and see them rendered on the canvas to see which works best. ➡️ Change variable by breakpoint "So you can make the variables look great, no matter the screen size." CSS variables in Webstudio use the same UI as the rest of your styles, enabling breakpoints to work the same way. ✨ Building with design systems gives a HUGE boost in speed, consistency, and maintainability.

Webstudio

15,497 просмотров • 2 лет назад