react-on-screen
react-on-screen copied to clipboard
Track_visibility does not work on mac safari browser
I check the props through console.log (props.isVisible) and it only returns true when there is a scroll event. Also on the screen when reloading the website is always false
I had a similar problem, what I did was to execute a scrolling for the <TrackVisibility>
to work. If you are having the problem on the initial render you can do the following:
Class based component
componentDidMount(){
window.scroll(0,1);
window.scroll(0,-1);
}
Functional component
React.useEffect(() => {
window.scroll(0,1);
window.scroll(0,-1);
}, [])
I had the same problem, on mobile browsers it didn't load either, I added once
and offset={ }
and everything worked perfectly.
<TrackVisibility
once
offset={400}
>
</TrackVisibility>