Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move blur event reset into non-touch handlers #11087

Merged
merged 4 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ui/handler/box_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ class BoxZoomHandler {
}
}

blur() {
this.reset();
}

reset() {
this._active = false;

Expand Down
4 changes: 4 additions & 0 deletions src/ui/handler/click_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export default class ClickZoomHandler {
this._active = false;
}

blur() {
this.reset();
}

dblclick(e: MouseEvent, point: Point) {
e.preventDefault();
return {
Expand Down
4 changes: 4 additions & 0 deletions src/ui/handler/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class KeyboardHandler {
this._rotationDisabled = false;
}

blur() {
this.reset();
}

reset() {
this._active = false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/ui/handler/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class MouseHandler {
this._clickTolerance = options.clickTolerance || 1;
}

blur() {
this.reset();
}

reset() {
this._active = false;
this._moved = false;
Expand Down
4 changes: 4 additions & 0 deletions src/ui/handler/scroll_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ class ScrollZoomHandler {
return easing;
}

blur() {
this.reset();
}

reset() {
this._active = false;
}
Expand Down
5 changes: 0 additions & 5 deletions src/ui/handler_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 6 additions & 2 deletions test/unit/ui/handler/drag_pan.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions test/unit/ui/handler/drag_rotate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down