Skip to content

Commit

Permalink
fix(image): swap height and width in portrait mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RouHim committed Nov 24, 2023
1 parent 31d74ec commit a3c1a3b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion web-app/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,20 @@ function getCurrentTemperatureDataFromHomeAssistant() {
*/
function setImage(resource_id) {
// build the image url
let imageUrl = `/api/resources/${resource_id}/${window.screen.availWidth}/${window.screen.availHeight}`;
let imageWidth, imageHeight;

if (window.screen.orientation.type.includes('portrait')) {
// In Portrait-Mode
// Swap width and height
imageWidth = window.screen.availHeight;
imageHeight = window.screen.availWidth;
} else {
// In Landscape-Mode
imageWidth = window.screen.availWidth;
imageHeight = window.screen.availHeight;
}

let imageUrl = `/api/resources/${resource_id}/${imageWidth}/${imageHeight}`;

// obtain the image elements
let backgroundImage = document.getElementById('background-image');
Expand Down

0 comments on commit a3c1a3b

Please sign in to comment.