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

Is there a way to disable mouse scroll on input value sliders? #83

Closed
Ararana opened this issue Jan 3, 2023 · 3 comments
Closed

Is there a way to disable mouse scroll on input value sliders? #83

Ararana opened this issue Jan 3, 2023 · 3 comments

Comments

@Ararana
Copy link

Ararana commented Jan 3, 2023

Currently if focus is put on a numerical slider, the mouse scroll wheel can be used to change it's value. Can this be disabled?

@georgealways
Copy link
Owner

Hi there—Unfortunately there's no built-in way to disable specific pieces of the number controller's functionality. I'd recommend using your fork for now, and we can discuss merging it into the lib if more requests come up. Thanks!

@georgealways
Copy link
Owner

Just to confirm, when you say focus, you mean "cursor on top of slider", correct? My intent was to make it so you could still scroll wheel by keeping your mouse on the right of the GUI.

In the interim, you could either use dipterix's fork, or comment out this line https://github.com/georgealways/lil-gui/blob/master/src/NumberController.js#L386.

(edit: Apologies @Ararana—I was conflating users here and thought the PR was yours)

@dipterix
Copy link

dipterix commented Jun 17, 2023

@Ararana I have a hack for this:

// controller is a NumberController
// controller = gui.add(...)
Object.defineProperty(controller, '_hasScrollBar', {
  get: function() { return true }
});

In this way you can trick the controller into thinking there is a scrollbar in its parent element, hence the controller scroll effect will go away (tested on the latest lil-gui). The benefit is you don't need to change any source code.

The reason why this is a hack is because it changes the prototype of _hasScrollBar property for NumberController. However, this hack is exactly what you might expect if the author wants to change their source code to fix this issue. This prototype pollution will not add vulnerability to your code.

@georgealways georgealways closed this as not planned Won't fix, can't repro, duplicate, stale Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants