3dmol / 3Dmol.js

WebGL accelerated JavaScript molecular graphics library
https://3dmol.org/
Other
813 stars 195 forks source link

[BUG] mac + mousewheel -> always zooms in at max zoom #682

Closed arogozhnikov closed 1 year ago

arogozhnikov commented 1 year ago

Describe the bug

here is how it looks on front page:

https://github.com/3dmol/3Dmol.js/assets/6318811/6f4cbc63-244c-4e80-b925-87ead208c870

mac os + mouse wheel + chromium-based browser. I move mousewheel to zoom out and then make a slight zoom-in - but the image zooms in completely. There is no way to slightly zoom in with mousewheel

ablations:

dkoes commented 1 year ago

I hooked up a scroll wheel mouse to my macbook and it behaved as expected.

If you look at chrome://flags are any of the options that deal with scrolling/mouse behavior set to something other than the default?

arogozhnikov commented 1 year ago

Hi @dkoes I did not change any flags, but I checked per your advice: Chrome-flags + searched for scroll and mouse - nothing non-default. Changed some parameters that could be related to non-default values - no effect on the bug. I have 3 independent chromium-based browsers and behavior is identical in all of them. I've tried connecting mouse via different connector - behavior is still the same. (I have very a simple logitech usb mouse)

As a control, I've tried nglview demo + chromium - and zooming via mouse scrolling works as expected.

dkoes commented 1 year ago

I'm using Chrome 114.0.5735.90 and macOS 13.3.1. I've tried both a generic wireless mouse and a logitech wireless mouse and I see the expected behavior.

Are you sure the problem isn't just that you are scrolling too quickly?

A single "click" of my logitech wheel produces a wheelDelta of 240 in Chrome but only 48 in Firefox (and interestingly on Linux using the same mouse Chrome produces 15).

It would be helpful if you could bring up the debugger and place a breakpoint in the scroll handling code (search for wheelDelta in 3Dmol.js) and let me know what a single wheel click on your system produces.

arogozhnikov commented 1 year ago
Screenshot 2023-05-30 at 2 16 40 PM

See logs: deltas are the same (though they are big). It is scale factor that changes. In this screenshot: 4 zoom-outs, one zoom-in (last one)

dkoes commented 1 year ago

And does this change if you change the mouse scroll speed in your system preferences?

image

Most likely the fix here is to have a scroll speed limit since there are obviously wildly different default values for a given scroll wheel motion across platforms.

arogozhnikov commented 1 year ago

yes, changing scroll speed helps!

Agree that just clipping delta at, say, 100 will solve the original issue