Answers for "react hook scroll left right on click"

0

toggle class onscroll hook react

const [scroll, setScroll] = useState(0)

  useEffect(() => {
    document.addEventListener("scroll", () => {
      const scrollCheck = window.scrollY < 100
      if (scrollCheck !== scroll) {
        setScroll(scrollCheck)
      }
    })
  })
Posted by: Guest on August-28-2020
0

horizontal scroll onclick react

const scroll = (scrollOffset) => {
  ref.current.scrollLeft += scrollOffset;
};

 <Row>
        <Col>
          <button onClick={() => scroll(-20)}>LEFT</button>
          <button onClick={() => scroll(20)}>RIGHT</button>
        </Col>
 </Row>
Posted by: Guest on December-03-2020

Code answers related to "react hook scroll left right on click"

Code answers related to "Javascript"

Browse Popular Code Answers by Language