joshwnj / react-visibility-sensor

Sensor component for React that notifies you when it goes in or out of the window viewport.
MIT License
2.32k stars 195 forks source link

How to set different behaviour for different visibility direction #124

Open aviramga opened 6 years ago

aviramga commented 6 years ago

Hi,

I have an svg animation and I would like to play it when someone scrolls into view from the top and play it in reverse if the scroll is from bottom to top.

Is this possible with this library?

Thanks

kinaya commented 5 years ago

I am also looking for this functionality. Does anyone know how to detect the direction of the scroll?

ghardin1314 commented 4 years ago

Just figured this out if anyone still needs it. You can use 2 different visibility sensors with partialVisibility='top' and 'bottom' and have different callbacks for each.