Assume we want to call these 2 function in this specific order:
scrollIntoView
an user-defined function foo to be called after scrollIntoView finishes (possible scrolling)
Assume we have added an event 'scroll' callback to call foo. Now, the problem is that if the target DOM element is already in view, scrollIntoView will not scroll. In that case, event 'scroll' won't occur.
How do we have foo called, whenever the asynchronous function scrollIntoView finishes scrolling or doesn't need to scroll at all?
In other words, how do we know function scrollIntoView will visually do nothing?
This question is similar to How to know scroll to element is done in Javascript?.