Is there a callback for window.scrollTo? : <p>I want to call <code>focus()</code> on an input after the widow scrolled. I'm using the smooth behavior for the <code>scrollTo()</code> method. The problem is the <code>focus</code> method cut the smooth behavior. The solution is to call the <code>focus</code> function just after the scroll end. </p>

<p>But I can't find any doc or threads speaking about how to detect the end of <code>scrollTo</code> method.</p>

<pre><code>let el = document.getElementById('input')
let elScrollOffset = el.getBoundingClientRect().top
let scrollOffset = window.pageYOffset || document.documentElement.scrollTop
let padding = 12
window.scrollTo({
  top: elScrollOffset + scrollOffset - padding,
  behavior: 'smooth'
})
// wait for the end of scrolling and then
el.focus()
</code></pre>

<p>Any ideas?</p>
