I'm using react-spring
and IntersectionObserver
to animate some div elements on my page.
For the IntersectionObserver
, I am using a hook given by the tutorial here.
While I am able to get the div to rotate by itself (onClick
), and the useIntersect
working - I am unable to trigger the rotation when the a section appears. I have tried using setState
, the same way I do for onClick
, but this does not work since the entry.isIntersecting
property triggers multiple time during each rerender.
How can I get a div to rotate using react-spring when an IntersectionObserver threshold is met?