From 8bc8c8a83b552d91da48c76dde777fcc00b5da11 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 16 Aug 2017 17:37:12 -0700 Subject: [PATCH] Fixup --- src/ui/handler/drag_rotate.js | 2 +- test/unit/ui/handler/drag_rotate.test.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ui/handler/drag_rotate.js b/src/ui/handler/drag_rotate.js index b204b0f2431..34f8b3d46ad 100644 --- a/src/ui/handler/drag_rotate.js +++ b/src/ui/handler/drag_rotate.js @@ -158,7 +158,7 @@ class DragRotateHandler { } _onUp(e: MouseEvent) { - window.document.removeEventListener('mousemove', this._onMove); + window.document.removeEventListener('mousemove', this._onMove, {capture: true}); window.document.removeEventListener('mouseup', this._onUp); window.removeEventListener('blur', (this._onUp: any)); diff --git a/test/unit/ui/handler/drag_rotate.test.js b/test/unit/ui/handler/drag_rotate.test.js index 0e3ba50ab75..13c25874c15 100644 --- a/test/unit/ui/handler/drag_rotate.test.js +++ b/test/unit/ui/handler/drag_rotate.test.js @@ -41,6 +41,25 @@ test('DragRotateHandler rotates in response to a right-click drag', (t) => { t.end(); }); +test('DragRotateHandler stops rotating after mouseup', (t) => { + const map = createMap(); + + simulate.mousedown(map.getCanvas(), {bubbles: true, buttons: 2, button: 2}); + simulate.mousemove(map.getCanvas(), {bubbles: true, buttons: 2}); + simulate.mouseup(map.getCanvas(), {bubbles: true, buttons: 0, button: 2}); + + const spy = t.spy(); + + map.on('rotatestart', spy); + map.on('rotate', spy); + map.on('rotateend', spy); + + simulate.mousemove(map.getCanvas(), {bubbles: true, buttons: 0}); + + t.ok(spy.notCalled); + t.end(); +}); + test('DragRotateHandler rotates in response to a control-left-click drag', (t) => { const map = createMap();