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

Detect element when it just show out on the screen ? #98

Closed imakou closed 6 years ago

imakou commented 7 years ago

Hi all,

Is there any way to detect(emit) listeners when the target element is shown on the screen? Basically, the current way is that element will be detected from shadow to the sun, that's no problem. How about to detect an element when it just shows in the sun(visible area) directly.

My case is a messaging app. I'd like to detect the newest message which has been read from senders. So, I need to trigger the newest message when it just shows on the screen. But the newest message is only detected by refresh browser rather than render dom. Or, it can be triggered by scroll to top and bottom.

Many thanks.

imakou commented 7 years ago

Just got the solution by add prop partialVisibility="top".

Thank you all the contributors of this project.