From 1c9e1b4f74892aadbacc2be5479e9bfbfc13cbaf Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 27 Nov 2023 20:10:35 +0000 Subject: [PATCH] Account for pages not having a hero Eg the homepage --- static/src/js/base.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/static/src/js/base.js b/static/src/js/base.js index f79c70c..dea0457 100644 --- a/static/src/js/base.js +++ b/static/src/js/base.js @@ -91,8 +91,13 @@ window.addEventListener("load", () => { }); window.addEventListener("DOMContentLoaded", () => { - setHeroHeight(); - handleHeroStuck(); + if (HERO) { + setHeroHeight(); + handleHeroStuck(); + + window.addEventListener("resize", debounce(setHeroHeight, 2000)); + window.addEventListener("scroll", throttle(handleHeroStuck, 100)); + } if (window.location.hash <= 1) { return; @@ -111,8 +116,3 @@ window.addEventListener("DOMContentLoaded", () => { scrollToElement(scrollTarget, "auto"); }); - -if (HERO) { - window.addEventListener("resize", debounce(setHeroHeight, 2000)); - window.addEventListener("scroll", throttle(handleHeroStuck, 100)); -}