Skip to content

map stuck in DragRotate when mouse up occurs outside an iframe #4622

Closed
@andrewharvey

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:

  1. User starts a DragRotate (either via Ctrl+left mouse or right mouse)
  2. Drags the cursor outside the iframe (with Ctrl or right mouse still down)
  3. Then releases Ctrl or right mouse outside the iframe
  4. 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.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions