From d8040733285c0b003b7822ab2a6fdd3f32f9fcb1 Mon Sep 17 00:00:00 2001 From: Alan Date: Sun, 14 Jul 2024 23:53:56 +0400 Subject: [PATCH] Fix bug with elements shifting on mobile --- js/main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index aede2da..1b93308 100644 --- a/js/main.js +++ b/js/main.js @@ -113,9 +113,13 @@ ready(() => { window.addEventListener('resize', function(event) { intro = _('.content').offsetTop; // set top of content - document.documentElement.style.setProperty('--vh', `${window.innerHeight * 0.01}px`) + // window.document.documentElement.clientHeight as opposed to window.innerHeight + // since using the former will prevent stuff from moving around when a mobile + // browser's address and navbar collapse - headerYOffset = (window.innerHeight)/10 - parseFloat(getComputedStyle(_("h2")).fontSize) - 5 + document.documentElement.style.setProperty('--vh', `${window.document.documentElement.clientHeight * 0.01}px`) + + headerYOffset = (window.document.documentElement.clientHeight)/10 - parseFloat(getComputedStyle(_("h2")).fontSize) - 5 updateHeaders() }, true);