Fix MOUSE_MOVE firing outside the canvas in Firefox#13576
Conversation
|
Thank you for the pull request, @eclctc! Welcome to the Cesium community! In order for us to review your PR, please complete the following steps:
Review Pull Request Guidelines to make sure your PR gets accepted quickly. |
|
I can confirm @eclctc has completed a CLA! |
|
I did a first review/test pass. Aside: I first thought that the inclusive check of More importantly: This does not seem to fully resolve the issue - or at least, not all "flavors" of this issue: When you move the mouse cursor over the timeline (at the bottom of the viewer), then the behavior is still different: Chrome does not fire events there. But FireFox still does fire events there, even with this fix. This is not entirely surprising when looking at the code: The event position is still contained in the main viewer. The fact that there is that "timeline widget" that is "on top of" the main viewer window is not anticipated there. In order to fix this, the check will probably have to include some check for another |
|
Sounds good! I'll have a look and circle back when once I've investigated. Thanks for letting me know :) |
Fixes #12373.
If you set a
MOUSE_MOVEaction, the events behave differently in Firefox vs Chrome. In Chrome they stop once the cursor leaves the canvas, but in Firefox they keep coming with coordinates outside the canvas (sometimes negative).I dug into it and the two browsers end up on different code paths. Chrome uses Pointer Events with
pointermoveon the canvas, so moving off-canvas just stops firing (and drags keep going thanks to pointer capture). Firefox has Pointer Events turned off (#6372), so it falls back to the old mouse path wheremousemoveis attached to thedocument. That's on purpose so drags still work when you go past the canvas edge — but the side effect is plain hover moves outside the canvas were firing too.The fix is in
handleMouseMove: if no mouse button is down, ignore moves that land outside the element bounds, which lines up with how the Pointer Event path already behaves. Drags (button held) still fire off-canvas so the camera controls aren't affected. Nothing changes for Chrome, and the bounds check only runs on hover so it's not in the way during a drag.Testing:
ScreenSpaceEventHandlerSpec.jsfor the off-canvas hover being ignored, drags still firing off-canvas, and the previous position not getting clobbered when a hover move is skipped.Checklist:
CONTRIBUTORS.md.CHANGES.mdwith a short description of my change.