Next.js Discord

Discord Forum

scroll animation

Unanswered
Sun bear posted this in #help-forum
Open in Discord
Avatar
Sun bearOP
is there better way to do scroll

4 Replies

Avatar
Sun bearOP
  const handleScroll = () => {
    questionRef.current?.nextElementSibling?.scrollIntoView({
      behavior: "smooth",
    });
  };
  const handleClick = (answer: string) => {
    if (answer === question.answer) {
      setScore((prev: number) => prev + 1);
      if (scrollOn) {
        requestAnimationFrame(() => {
          questionRef.current?.nextElementSibling?.scrollIntoView({
            behavior: "smooth",
          });
        });
      }
    }
  };  
when i choose some answer sirtly some blocks are rendered and after that scrolled to next sibling
Image
but at some moment its annyoing when you see 2 thing happen at the same time