I have a small website that starts to scroll to show user the entire content after some short time of inactivity.
I have one event listener that listens if user is active and if not it starts scrolling automatically. The problem is that this automatic scroll makes the website think that it's scroll by the user, which is not.
Is there a way how to tell difference if the scroll is done by user or by JavaScript?
// this line in an infinite loop using is causing the page to scroll
window.scrollTo(0, 200)
// this is detecting the scrolling
window.onscroll = (event) => {
// maybe get the information somehow from the event??
if (event.scrolledBy == 'user'){
activity = true
}
}
can't I duplicate the function and set some sort of id of it? Let's say
window.scrollToAutomat = window.scrollTo
and then do some magic?