Skip to content

Commit

Permalink
fix DragRotateHandler#isActive (#9511) (#9515)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Apr 8, 2020
1 parent 164b0be commit 97037a4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ui/handler/shim/drag_rotate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
24 changes: 24 additions & 0 deletions test/unit/ui/handler/drag_rotate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 97037a4

Please sign in to comment.