-
Notifications
You must be signed in to change notification settings - Fork 757
Closed
Labels
Description
Right now you can't really tell if scrollIntoView scroll animation has finished nor you can't control the speed of the scroll and it might differ with each browser. So if you want to perform some action right after the animation has finished there's no determined way to do that. Having an onAnimationEnd callback as an initializer option would solve this problem:
Element.scrollIntoView({
onAnimationEnd: () => Element.focus()
})Why we would ever need that?
Imagine that you have some input you would like to focus that's out of the viewport boundaries right now, but you would also like to have a smooth scrolling animation to that input. If you execute focus before scrollIntoView then you'll get no scroll animation, because browser will
already scroll to that input without animation.
DrummerHead, codemacabre, Dan503, edwyn-amador, mirko-kienle and 252 morevyomGupta736moshfeu, sniperwolf, GiuseppePennisi, UvealSnow, igregson and 5 more