Skip to content

Commit

Permalink
Merge pull request #1771 from xeokit/fix/XEOK-171
Browse files Browse the repository at this point in the history
XEOK-171: CameraControl stops reacting when using system shortcuts
  • Loading branch information
xeolabs authored Jan 3, 2025
2 parents 98913a0 + 2da2769 commit 3ee2a14
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ class KeyboardPanRotateDollyHandler {
}
});

document.addEventListener("visibilitychange", this._onVisibilityChange = () => {
keyDownMap.splice(0);
})

window.addEventListener("blur", this._onBlur = () => {
keyDownMap.splice(0);
})

this._onTick = scene.on("tick", (e) => {

if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
Expand Down Expand Up @@ -168,6 +176,8 @@ class KeyboardPanRotateDollyHandler {

this._scene.input.off(this._onSceneMouseMove);
this._scene.input.off(this._onSceneKeyDown);
document.removeEventListener("visibilitychange", this._onVisibilityChange);
window.removeEventListener("blur", this._onBlur);
this._scene.input.off(this._onSceneKeyUp);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ class MousePanRotateDollyHandler {
keyDown[keyCode] = false;
});

document.addEventListener("visibilitychange", this._onVisibilityChange = () => {
keyDown.splice(0);
})

window.addEventListener("blur", this._onBlur = () => {
keyDown.splice(0);
})

function setMousedownState(pick = true) {
setMousedownPositions();
if (pick) {
Expand Down Expand Up @@ -355,6 +363,8 @@ class MousePanRotateDollyHandler {

document.removeEventListener("keydown", this._documentKeyDownHandler);
document.removeEventListener("keyup", this._documentKeyUpHandler);
document.removeEventListener("visibilitychange", this._onVisibilityChange);
window.removeEventListener("blur", this._onBlur);
canvas.removeEventListener("mousedown", this._mouseDownHandler);
document.removeEventListener("mousemove", this._documentMouseMoveHandler);
canvas.removeEventListener("mousemove", this._canvasMouseMoveHandler);
Expand Down

0 comments on commit 3ee2a14

Please sign in to comment.