diff --git a/src/ui/handler/box_zoom.js b/src/ui/handler/box_zoom.js index 96c6dacac87..e76e3e117e1 100644 --- a/src/ui/handler/box_zoom.js +++ b/src/ui/handler/box_zoom.js @@ -153,6 +153,10 @@ class BoxZoomHandler { } } + blur() { + this.reset(); + } + reset() { this._active = false; diff --git a/src/ui/handler/click_zoom.js b/src/ui/handler/click_zoom.js index 19362ede8c0..44d29f26976 100644 --- a/src/ui/handler/click_zoom.js +++ b/src/ui/handler/click_zoom.js @@ -16,6 +16,10 @@ export default class ClickZoomHandler { this._active = false; } + blur() { + this.reset(); + } + dblclick(e: MouseEvent, point: Point) { e.preventDefault(); return { diff --git a/src/ui/handler/keyboard.js b/src/ui/handler/keyboard.js index eb04f773aae..b5bc103ff74 100644 --- a/src/ui/handler/keyboard.js +++ b/src/ui/handler/keyboard.js @@ -45,6 +45,10 @@ class KeyboardHandler { this._rotationDisabled = false; } + blur() { + this.reset(); + } + reset() { this._active = false; } diff --git a/src/ui/handler/mouse.js b/src/ui/handler/mouse.js index d1a94551476..059e024cea6 100644 --- a/src/ui/handler/mouse.js +++ b/src/ui/handler/mouse.js @@ -31,6 +31,10 @@ class MouseHandler { this._clickTolerance = options.clickTolerance || 1; } + blur() { + this.reset(); + } + reset() { this._active = false; this._moved = false; diff --git a/src/ui/handler/scroll_zoom.js b/src/ui/handler/scroll_zoom.js index 74084468297..0eb62460891 100644 --- a/src/ui/handler/scroll_zoom.js +++ b/src/ui/handler/scroll_zoom.js @@ -371,6 +371,10 @@ class ScrollZoomHandler { return easing; } + blur() { + this.reset(); + } + reset() { this._active = false; } diff --git a/src/ui/handler_manager.js b/src/ui/handler_manager.js index b9b4e3a12ca..a3fa767706c 100644 --- a/src/ui/handler_manager.js +++ b/src/ui/handler_manager.js @@ -344,11 +344,6 @@ class HandlerManager { handleEvent(e: InputEvent | RenderFrameEvent, eventName?: string) { - if (e.type === 'blur') { - this.stop(true); - return; - } - this._updatingCamera = true; assert(e.timeStamp !== undefined); diff --git a/test/unit/ui/handler/drag_pan.test.js b/test/unit/ui/handler/drag_pan.test.js index f70d5c7702a..98ea491a2ca 100644 --- a/test/unit/ui/handler/drag_pan.test.js +++ b/test/unit/ui/handler/drag_pan.test.js @@ -151,13 +151,15 @@ test('DragPanHandler ends a mouse-triggered drag if the window blurs', (t) => { map._renderTaskQueue.run(); simulate.blur(window); + map._renderTaskQueue.run(); + t.equal(dragend.callCount, 1); map.remove(); t.end(); }); -test('DragPanHandler ends a touch-triggered drag if the window blurs', (t) => { +test('DragPanHandler does not end a touch-triggered drag if the window blurs', (t) => { const map = createMap(t); const target = map.getCanvas(); @@ -171,7 +173,9 @@ test('DragPanHandler ends a touch-triggered drag if the window blurs', (t) => { map._renderTaskQueue.run(); simulate.blur(window); - t.equal(dragend.callCount, 1); + map._renderTaskQueue.run(); + + t.equal(dragend.callCount, 0); map.remove(); t.end(); diff --git a/test/unit/ui/handler/drag_rotate.test.js b/test/unit/ui/handler/drag_rotate.test.js index 4fe68a46fd2..f12c0eba8bb 100644 --- a/test/unit/ui/handler/drag_rotate.test.js +++ b/test/unit/ui/handler/drag_rotate.test.js @@ -492,6 +492,8 @@ test('DragRotateHandler ends rotation if the window blurs (#3389)', (t) => { t.equal(rotate.callCount, 1); simulate.blur(window); + map._renderTaskQueue.run(); + t.equal(rotateend.callCount, 1); map.remove();