darkroomengineering / lenis

How smooth scroll should be
https://lenis.darkroom.engineering
MIT License
7.35k stars 315 forks source link

The “lenis-scrolling” class is removed on touch scrolling #284

Closed Beavykins closed 4 months ago

Beavykins commented 5 months ago

When using Lenis on touch devices the “lenis-scrolling” class is removed before touch end.

If you start a touch, do a touch move and then stop moving without releasing the “lenis-scrolling” class is removed when the scroll stops. As soon as you move again the class is re-added. I assume this is because it has detected that the movement/lerp has finished even though technically you are still scrolling.

The expected behaviour is that the “lenis-scrolling” class is only removed on touch end or after touch end if lerp is still going.

Thanks!

clementroche commented 5 months ago

I don't think that's wrong. Do you see a context where it causes an issue ?

Beavykins commented 5 months ago

I notice it tends to happen quite a lot as you are touch scrolling, sometimes even before it seems to have stopped, probably due to some kind of check on the lerp being under a certain value?

If you are styling anything based on that “lenis-scrolling” class then the style will keep going on and off even though it seems like you are scrolling still, you just happen to have paused the movement for a short time.

Also I don’t think it is in the docs but the “class change” event that is being emitted will also update, so if that is being used to determine if a scroll has completed or started then it’s inaccurate. That is probably not intended for external use but though…

Beavykins commented 5 months ago

Take the scrollbar on iOS for example, as soon as you touch move and scroll the scrollbar appears, it doesn’t disappear if you stop moving your finger, it waits for you to stop touching as it sees the action as a completed scroll, not just the movement stopping.

clementroche commented 4 months ago

You can still implement this by yourself by listening to touchStart/touchEnd, i don't think this should be done by Lenis itself. "lenis-scrolling" is correct imo