joshwnj / react-visibility-sensor

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

partialVisibility bottom remains visible when the viewport is below the component #158

Open wescorwin opened 5 years ago

wescorwin commented 5 years ago

Hello!

This library has been very useful but there's a small functionality issue with partialVisibility that I'm not sure works as intended.

When partialVisibility is set to 'bottom', the sensor triggers when the bottom of the element is visible (as desired). But then, when the user scrolls away from the element, to the point that the card is out of the viewport, the sensor still claims the element is visible.

In the below demo, try changing partialVisibility to 'bottom' then scroll below the red bar. You'll observe that the output claims "Contained Element is now visible"

https://codepen.io/joshwnj/pen/PjwVym