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
Mousewheel zoom broken and resolution constraints not respected in Firefox #1789
Conversation
#436 and #843 report the same problem. Mac OS X seems to create its own mouse wheel zoom events when using the trackpad. The trackpad can easily generate tens of mouse wheel events. However, zooming with a real mouse wheel only generates a single event. I suspect that Chrome and Safari look at the device generating the mouse wheel events and handle the trackpad and the mousewheel differently, but that Firefox does not. However, it should not be possible to end up on an unconstrained resolution, so there's a bug in ol3 too. |
Note that this seems specific to Firefox on Mac OS X. I'm unable to reproduce the problem on Firefox 27 on Ubuntu. |
So browser issue aside, I almost got crazy looking to see why the constraints are ignored, and I do not have the slightest clue. |
I agree, I have no idea why the constraints are being ignored. I'll try some debugging when my Mac comes back from repair... |
Thanks @twpayne, much appreciated! |
According to this thread on the mailing list, the ignored constraints are an issue not specific to Firefox. |
If you do I tried to reproduce the getZoom return undefined issue in FireFox/Linux but I couldn't. |
Yes, |
The weird part it that the mousewheel interaction always zooms the view to constrained resolutions. See https://github.com/openlayers/ol3/blob/master/src/ol/interaction/interaction.js#L175-177. |
It looks like I see basically two ways to handle this: either change the constraint function to round the delta, or to change the mousewheel code to not divide the delta by 3. I'm attaching a pull request that does the latter, because I do not notice a change in behavior in other browsers (as opposed to rounding the delta before calling the constraint function). |
Pull request attached. |
Thanks very much for investigating this @ahocevar! This patch seems to fix the problem on Firefox on Mac OS X. It does make zooming very fast though, but I'd suggest addressing that in a different PR since this fixes a significant bug. |
+1 |
Thanks for the reviews. I think it will make sense to revisit this when the pointerevents branch is merged. It might make sense to get rid of the |
Mousewheel zoom broken and resolution constraints not respected in Firefox
Yes, but the constraint used allows fractional zoom levels when the delta is not an integer. It's more a strategy for calculating a zoom level than a constraint. See https://github.com/openlayers/ol3/blob/master/src/ol/resolutionconstraint.js#L65-70. |
I was unable to figure out what is wrong, but this issue can be easily reproduced. It only happens in Firefox:
map.getView().getView2D().getZoom()
. You are very likely to getundefined
, which means we have an unconstrained resolution.Any ideas?