Change viewport based on device orientation.

This commit is contained in:
Jared 2021-01-04 07:11:12 -08:00 committed by Jared Goodwin
parent 55c7ce34a3
commit ffbd8d5821

View File

@ -23,6 +23,9 @@ export function ApplyInputEventHandlers() {
window.addEventListener("resize", ev => {
PositionCommandCompletionWindow();
});
setViewportWidth();
window.addEventListener("orientationchange", setViewportWidth);
}
function addGridPaginationHandlers() {
@ -258,4 +261,16 @@ function keyDownOnWindow() {
UI.ConsoleOutputDiv.innerHTML = "";
}
});
}
function setViewportWidth() {
if (window.screen?.orientation?.type?.includes("portrait")) {
var desiredWidth = Math.max(550, window.screen.width);
document.querySelector('meta[name="viewport"').setAttribute("content", `width=${desiredWidth}, user-scalable=no`);
}
else {
var desiredHeight = Math.max(700, window.screen.height);
document.querySelector('meta[name="viewport"').setAttribute("content", `width=device-width, height=${desiredHeight}, user-scalable=no`);
}
console.log(window.screen);
}