Skip to content

NumberController behaves weird when scrolling mousewheel #46

@InCogNiTo124

Description

@InCogNiTo124

I define my NumberController like:

const folder = gui.addFolder("elements");
folder.add(state, 'a', 0.1).min(0).step(0.1);

Keyboard arrow-up and arrow-down work correctly. However, mouse scrolling event increases and decreases the values by 5.3 😕 the same behaviour is experienced with a dofferent controller (the sliders) where keyboards change the value by 0.015 but mouse wheel changes the value by 0.0795 (also 5.3 times larger).

I noticed these lines when searching for the problem:

_normalizeMouseWheel( e ) {
let { deltaX, deltaY } = e;
// Safari and Chrome report weird non-integral values for a notched wheel,
// but still expose actual lines scrolled via wheelDelta. Notched wheels
// should behave the same way as arrow keys.
if ( Math.floor( e.deltaY ) !== e.deltaY && e.wheelDelta ) {
deltaX = 0;
deltaY = -e.wheelDelta / 120;
deltaY *= this._stepExplicit ? 1 : 10;
}
const wheel = deltaX + -deltaY;
return wheel;
}

Maybe the magic 120 is wrongly hardcoded? But I can't even grasp my head around what the value would depend on...

I use Brave Browser:
Version 1.36.83 Chromium: 98.0.4758.87 (Official Build) beta (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions