map stuck in DragRotate when mouse up occurs outside an iframe #4622
Closed
Description
mapbox-gl-js version: 0.36.0
Steps to Trigger Behavior
Similar to #3389, when a map appears in an iframe (eg. https://www.mapbox.com/mapbox-gl-js/examples/) and:
- User starts a DragRotate (either via Ctrl+left mouse or right mouse)
- Drags the cursor outside the iframe (with Ctrl or right mouse still down)
- Then releases Ctrl or right mouse outside the iframe
- Move the mouse back in the iframe and the map is stuck in drag rotate mode.
Possible Solution
Similar to the other solution #4390 we can detect when the mouse leaves the iframe with
window.addEventListener('mouseout', function (e) {
if (e.toElement === null) {
// mouse left iframe
}
});
However we probably want to allow users to DragRotate even with the mouse leaving the iframe, and only prevent the limited case where the mouse up occurs outside, so I'm guessing we might want to check the first mousemove
on the map after a window mouseout
event if the Ctrl or right mouse is still down, and if not end the interaction.