diff --git a/static/scripts/mobileViewportHeight.js b/static/scripts/mobileViewportHeight.js index 8022a5d..05db48b 100644 --- a/static/scripts/mobileViewportHeight.js +++ b/static/scripts/mobileViewportHeight.js @@ -1,13 +1,17 @@ -// First we get the viewport height and we multiple it by 1% to get a value for a vh unit +var root = document.documentElement; let vh = window.innerHeight * 0.01; -// Then we set the value in the --vh custom property to the root of the document -document.documentElement.style.setProperty('--vh', `${vh}px`); +root.style.setProperty('--vh', `${vh}px`); +this.lastHeight = window.innerHeight; -/* // We listen to the resize event window.addEventListener('resize', () => { // We execute the same script as before - let vh = window.innerHeight * 0.01; - document.documentElement.style.setProperty('--vh', `${vh}px`); + if ( + window.innerWidth > window.innerHeight || + Math.abs(this.lastHeight - window.innerHeight) > 100 + ) { + let vh = window.innerHeight * 0.01; + root.style.setProperty('--vh', `${vh}px`); + this.lastHeight = window.innerHeight; + } }); -*/ \ No newline at end of file