From 34d8cb47164df5e35bfcc86603ecf0dd76b01f9d Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 9 Jul 2024 03:18:11 +0400 Subject: [PATCH] Minor visual fix --- js/main.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index 25f6cf0..8d2e77f 100644 --- a/js/main.js +++ b/js/main.js @@ -112,14 +112,19 @@ ready(() => { // fire when window resized, e.g. when device is turned window.addEventListener('resize', function(event) { intro = _('.content').offsetTop; // set top of content + headerYOffset = (window.innerHeight)/10 - parseFloat(getComputedStyle(_("h2")).fontSize) - 5 + updateHeaders() }, true); document.addEventListener('scroll', () => { // Update scroll position on scroll scrollPos = window.scrollY - + updateHeaders() + }) + + function updateHeaders() { sections.forEach((section, i) => { const rect = section.getBoundingClientRect() @@ -133,7 +138,7 @@ ready(() => { } } }) - }) + } // run every 150ms, put most things-that-change-with-scrolling here. // more efficient than putting them in the scroll event