Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally disable smooth scrolling on trackpads #237

Open
blehn opened this issue Oct 1, 2023 · 5 comments
Open

Optionally disable smooth scrolling on trackpads #237

blehn opened this issue Oct 1, 2023 · 5 comments
Labels

Comments

@blehn
Copy link

blehn commented Oct 1, 2023

Lenis seems to work pretty nicely with a mousewheel, but on MacOS, the native trackpad already has smooth scrolling with acceleration and momentum. Adding Lenis smooth scrolling on top of that makes scrolling feel too loose and unresponsive. There's no official trackpad detection that I know of, but it seems that there are some solutions: https://stackoverflow.com/questions/10744645/detect-touchpad-vs-mouse-in-javascript. I'd love to be able to enable or disable Lenis for trackpads and mousewheels independently.

@clementroche
Copy link
Member

clementroche commented Oct 2, 2023

https://codepen.io/ClementRoche/pen/eYbLWLV

This needs to be tested on different devices, not only MacOS

@arzafran
Copy link
Contributor

arzafran commented Oct 3, 2023

this is a tricky one, i'm using a Logi MX Master 3 mouse on MacOS Sonoma, and the wheel is detected as trackpad..
i don't think there's a reliable way to detect trackpad only.

@Krislunde
Copy link

https://codepen.io/ClementRoche/pen/eYbLWLV

This needs to be tested on different devices, not only MacOS

@clementroche This detects my macOS M1 touchpad as a mousewheel - unless I scroll sideways then it detects the track pad.

@philkunz
Copy link

philkunz commented Feb 1, 2025

I solved it, I think. See here:
https://philkunz.com

Just scroll a little bit and it should switch to native scrolling when using Apple's Touchpad.

The logic is in this class:
https://code.foss.global/design.estate/dees-domtools/src/branch/master/ts/domtools.classes.scroller.ts

Basically I'm searching for the smooth scroll diffs created by Apple's touchpad. So when you enable Lenis, you may disable it after a sample size of a 100 scroll events when it turns out the scroll input is smooth already.

@clementroche
Copy link
Member

clementroche commented Feb 5, 2025

@philkunz how much scroll is 100 "wheel" events on a trackpad? like one finger swipe? I noticed that scrolling your website using Logitech mouse wheel, it detects a trackpad and disable lenis. Perhaps it requires some fine tuning but it doesn't loook that realiable given the variety of scrolling device on the market.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants