🏡 index : ~doyle/chartered.git

author Jordan Doyle <jordan@doyle.la> 2021-09-28 18:13:00.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2021-09-28 18:13:00.0 +01:00:00
commit
e460649b57c3e4d059b970e48f9f04cc4c59132d [patch]
tree
3c2bdfb9394693ad96a2ff71b1b759f78fdcebc3
parent
797ddfa046c70bea55313ee48e66bdb1c362608b
download
e460649b57c3e4d059b970e48f9f04cc4c59132d.tar.gz

Call overscrollColourFixer on initial page load



Diff

 chartered-frontend/src/overscrollColourFixer.ts | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/chartered-frontend/src/overscrollColourFixer.ts b/chartered-frontend/src/overscrollColourFixer.ts
index 2a23da9..1701d96 100644
--- a/chartered-frontend/src/overscrollColourFixer.ts
+++ a/chartered-frontend/src/overscrollColourFixer.ts
@@ -6,19 +6,18 @@
window.addEventListener("load", () => {
  let ticking;

  window.addEventListener(
    "scroll",
    function (event) {
      if (!ticking) {
        ticking = true;
  const backgroundFix = () => {
    if (!ticking) {
      ticking = true;

        window.requestAnimationFrame(() => {
          document.documentElement.style.backgroundColor =
            window.scrollY > 70 ? "var(--bs-primary)" : "#fff";
          ticking = false;
        });
      }
    },
    false
  );
      window.requestAnimationFrame(() => {
        document.documentElement.style.backgroundColor =
          window.scrollY > 70 ? "var(--bs-primary)" : "#fff";
        ticking = false;
      });
    }
  };

  window.addEventListener("scroll", backgroundFix, false);
  backgroundFix();
});