react-on-screen icon indicating copy to clipboard operation
react-on-screen copied to clipboard

Track_visibility does not work on mac safari browser

Open thienthu1221 opened this issue 5 years ago • 2 comments

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

thienthu1221 avatar Nov 15 '19 03:11 thienthu1221

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);
}, [])

ddanielcruzz avatar Mar 19 '20 22:03 ddanielcruzz

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>

wiliamvj avatar Apr 18 '20 21:04 wiliamvj