mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 09:09:30 -07:00
resizing for orientation change
This commit is contained in:
@@ -23,7 +23,8 @@ const navigation = (() => {
|
||||
let almanac;
|
||||
|
||||
const init = async () => {
|
||||
// nothing to do
|
||||
// set up resize handler
|
||||
window.addEventListener('resize', resize);
|
||||
};
|
||||
|
||||
const message = (data) => {
|
||||
@@ -262,6 +263,20 @@ const navigation = (() => {
|
||||
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 {
|
||||
init,
|
||||
message,
|
||||
@@ -273,5 +288,6 @@ const navigation = (() => {
|
||||
getDisplay,
|
||||
getCurrentWeather,
|
||||
getSun,
|
||||
resize,
|
||||
};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user