-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
mouseleave event not triggered/available #10594
Comments
Hi, @ygoe. Unless there's a specific reason why your workaround doesn't work, I think it's actually the appropriate solution in this case. Events on the See for example: Create a hover effect. |
I've seen that example but it didn't show what I wanted to do. Alright, I understand that |
Thanks for catching that, @ryanhamley, and apologies I missed the |
I looked up the difference between mouseout and mouseleave on MDN and found that mouseleave is the more robust one that I need to use. mouseout can lead to unexpected behaviour. Anyway, the DOM functions work fine now. |
mapbox-gl-js version: latest
browser: all
This will not be called when the mouse cursor leaves the map on the page:
No error is shown either.
I only found a related issue #4772 that has interesting links. The documentation says (somewhere far down) that the "mouseleave" event can only be subscribed for single layers, but it should also fire when the mouse leaves the map canvas altogether.
Now I need exactly the second part of the description. I don't care about layers, I don't even know (yet) what they are. I need an event when the mouse is no longer over the map canvas.
I'm not sure if this is a technical limitation or what the cause is. I'm just wondering why that event was missed out. Everything else works fine, but not this one.
Workaround
Don't use the
on
method for this event but fall back to the good oldaddEventListener
on the map's DOM element. That call will stick out from the others and definitely needs explanation in my source code.A more complete example of this can be found in my workaround code for another issue.
The text was updated successfully, but these errors were encountered: