jlmakes / scrollreveal

Animate elements as they scroll into view.
https://scrollrevealjs.org/
22.3k stars 2.26k forks source link

ScrollReveal doesn't work with react-snap on first load, but after navigating with react-router to any page and come back again, is starts working on the same page #564

Open burakkbilginn opened 9 months ago

burakkbilginn commented 9 months ago

As stated on the title, ScrollReveal doesn't work with react-snap on first load, but after navigating (with react-router) to any page and come again, is starts working on the same page. The code is like this:

 var slideFromBottom = {
    distance: "40%",
    origin: "bottom",
    opacity: 0,
    duration: 1000,
    easing: "ease-out",
    reset: true,
    mobile: true,
  }
  useEffect(()=>{
      setTimeout(() => ScrollReveal().delegate(), 250)
      ScrollReveal().reveal(".modalContainer", slideFromBottom)
   },[])

Should I use a different library? Or maybe is there a way to handle this problem occuring with react-snap library(creating static html)?

Environment