Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add class in element on scroll

const [scroll, setScroll] = useState(false);
 useEffect(() => {
   window.addEventListener("scroll", () => {
     setScroll(window.scrollY > 50);
   });
 }, []);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #class #element #scroll
ADD COMMENT
Topic
Name
2+7 =