Reputation: 639
Assume we want to call these 2 function in this specific order:
scrollIntoView
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?.
Upvotes: 1
Views: 314
Reputation: 1145
Check if element is in view https://stackoverflow.com/a/125106/19617075 and perform scrollIntoView or foo based on that.
Upvotes: 1