I'm trying to detect window position on scroll but the window.onscroll = () => {} function doesn't work in Safari, although it works fine in Chrome and Firefox.
myFunction() {
window.onscroll = () =>{
if(someCondition){
...do something
}
}
}
For some reason, Safari is the only browser where I can't log anything inside the window.onscroll function. I'm binding the function in the constructor and attaching it to a scroll event when the component mounts.
Does anyone know why this might be happening?
Following script works from me on safari. Please try.