From 40e18862b51a4046cb81fe95a321bbd949b997b6 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 8 Apr 2020 00:59:01 -0400 Subject: [PATCH] fix DragRotateHandler#isActive --- src/ui/handler/shim/drag_rotate.js | 2 +- test/unit/ui/handler/drag_rotate.test.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/ui/handler/shim/drag_rotate.js b/src/ui/handler/shim/drag_rotate.js index 5d3878b9f7d..22141fa5116 100644 --- a/src/ui/handler/shim/drag_rotate.js +++ b/src/ui/handler/shim/drag_rotate.js @@ -62,6 +62,6 @@ export default class DragRotateHandler { * @returns {boolean} `true` if the "drag to rotate" interaction is active. */ isActive() { - return this._mouseRotate.isEnabled() || this._mousePitch.isEnabled(); + return this._mouseRotate.isActive() || this._mousePitch.isActive(); } } diff --git a/test/unit/ui/handler/drag_rotate.test.js b/test/unit/ui/handler/drag_rotate.test.js index 84235f1d20c..d1107828606 100644 --- a/test/unit/ui/handler/drag_rotate.test.js +++ b/test/unit/ui/handler/drag_rotate.test.js @@ -11,6 +11,30 @@ function createMap(t, options) { return new Map(extend({container: DOM.create('div', '', window.document.body)}, options)); } +test('DragRotateHandler#isActive', (t) => { + const map = createMap(t); + + // Prevent inertial rotation. + t.stub(browser, 'now').returns(0); + + t.equal(map.dragRotate.isActive(), false); + + simulate.mousedown(map.getCanvas(), {buttons: 2, button: 2}); + map._renderTaskQueue.run(); + t.equal(map.dragRotate.isActive(), false); + + simulate.mousemove(map.getCanvas(), {buttons: 2, clientX: 10, clientY: 10}); + map._renderTaskQueue.run(); + t.equal(map.dragRotate.isActive(), true); + + simulate.mouseup(map.getCanvas(), {buttons: 0, button: 2}); + map._renderTaskQueue.run(); + t.equal(map.dragRotate.isActive(), false); + + map.remove(); + t.end(); +}); + test('DragRotateHandler fires rotatestart, rotate, and rotateend events at appropriate times in response to a right-click drag', (t) => { const map = createMap(t);