Skip to content

Commit

Permalink
Fix bug with elements shifting on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
alanrme committed Jul 14, 2024
1 parent 44c08ba commit d804073
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d804073

Please sign in to comment.