resizing for orientation change

This commit is contained in:
Matt Walsh 2022-09-23 15:55:37 -05:00
parent 3d7e93947b
commit 95b135a9b7
5 changed files with 24 additions and 40 deletions

View file

@ -233,7 +233,7 @@ const index = (() => {
window.scrollTo(0, 0); window.scrollTo(0, 0);
FullScreenOverride = true; FullScreenOverride = true;
} }
navigation.resize();
UpdateFullScreenNavigate(); UpdateFullScreenNavigate();
}; };
@ -254,6 +254,7 @@ const index = (() => {
} else if (document.msExitFullscreen) { } else if (document.msExitFullscreen) {
document.msExitFullscreen(); document.msExitFullscreen();
} }
navigation.resize();
}; };
const btnNavigateMenuClick = () => { const btnNavigateMenuClick = () => {

View file

@ -23,7 +23,8 @@ const navigation = (() => {
let almanac; let almanac;
const init = async () => { const init = async () => {
// nothing to do // set up resize handler
window.addEventListener('resize', resize);
}; };
const message = (data) => { const message = (data) => {
@ -262,6 +263,20 @@ const navigation = (() => {
return almanac.getSun(); return almanac.getSun();
}; };
// resize the container on a page resize
const resize = () => {
const widthZoomPercent = window.innerWidth / 640;
const heightZoomPercent = window.innerHeight / 480;
const scale = Math.min(widthZoomPercent, heightZoomPercent);
if (scale < 1.0 || document.fullscreenElement) {
document.getElementById('container').style.zoom = scale;
} else {
document.getElementById('container').style.zoom = 1;
}
};
return { return {
init, init,
message, message,
@ -273,5 +288,6 @@ const navigation = (() => {
getDisplay, getDisplay,
getCurrentWeather, getCurrentWeather,
getSun, getSun,
resize,
}; };
})(); })();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -240,9 +240,7 @@ jsgif {
#container { #container {
position: relative; position: relative;
width: 100%; width: 100%;
/* max-width: 640px; */
height: 100%; height: 100%;
max-height: 480;
background-image: url(../images/BackGround1_1.png); background-image: url(../images/BackGround1_1.png);
} }
@ -304,7 +302,6 @@ jsgif {
} }
#divTwc:fullscreen #display { #divTwc:fullscreen #display {
position: relative; position: relative;
} }
@ -318,36 +315,6 @@ jsgif {
bottom: 0px; bottom: 0px;
} }
@media screen and (orientation: portrait) {
#divTwc:fullscreen canvas {
width: 100vw;
max-width: 100vw;
height: auto;
}
#divTwc:fullscreen #container {
width: 100vw;
height: auto;
max-height: unset;
max-width: unset;
}
}
@media screen and (orientation: landscape) {
#divTwc:fullscreen canvas {
height: 100vh;
max-height: 100vh;
width: auto;
}
#divTwc:fullscreen #container {
height: 100vh;
width: auto;
max-width: 100vw;
max-height: unset;
}
}
.navButton { .navButton {
cursor: pointer; cursor: pointer;
} }