It is known that scroll event could be fired up by using mouse-wheel, clicking on scrollbar arrows or dynamically with window.scrollTo(left, top) function.
Is it possible to determine what caused the scroll event to fire up? Whether it was user intervention or JS code?
I don’t think you can determine what caused the scrolling. The scroll event only indicates that the window is scrolling, not why it’s scrolling.
But perhaps you suspend the scroll event listener or set a flag before calling
window.scrollTo()from your code. Here in Safari, if you usescrollTo(), the scroll event only fires once regardless of how much you scroll, so you could conceivably do something like this:It ain’t pretty, but it ought to work