diff --git a/src/sections/Company/Brand/index.js b/src/sections/Company/Brand/index.js index fd8c06b7f72ef..e0130ac4ad7c6 100644 --- a/src/sections/Company/Brand/index.js +++ b/src/sections/Company/Brand/index.js @@ -91,9 +91,15 @@ const easeOutCuaic = (t) => { const Brand = () => { const [scroll, setScroll] = useState(false); useEffect(() => { - window.addEventListener("scroll", () => - window.scrollY > 510 ? setScroll(true) : setScroll(false) - ); + const handleScroll = () => { + setScroll(window.scrollY > 510); + }; + + window.addEventListener("scroll", handleScroll, { passive: true }); + + return () => { + window.removeEventListener("scroll", handleScroll); + }; }, []); const [visibleSection, setVisibleSection] = useState(); diff --git a/src/sections/General/Navigation/index.js b/src/sections/General/Navigation/index.js index bc85cb22960a6..129e8cc83056b 100644 --- a/src/sections/General/Navigation/index.js +++ b/src/sections/General/Navigation/index.js @@ -262,9 +262,15 @@ const Navigation = () => { }, [expand]); useEffect(() => { - window.addEventListener("scroll", () => - window.scrollY > 50 ? setScroll(true) : setScroll(false) - ); + const handleScroll = () => { + setScroll(window.scrollY > 50); + }; + + window.addEventListener("scroll", handleScroll, { passive: true }); + + return () => { + window.removeEventListener("scroll", handleScroll); + }; }, []); const openDropDown = () => {