W3C home > Mailing lists > Public > public-css-archive@w3.org > March 2019

[csswg-drafts] [cssom-view-1] Provide onAnimationEnd callback in scrollIntoView options (#3744)

From: Stanislav Lashmanov via GitHub <sysbot+gh@w3.org>
Date: Tue, 19 Mar 2019 12:18:48 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-422700718-1552997927-sysbot+gh@w3.org>
CyberAP has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-view-1] Provide onAnimationEnd callback in scrollIntoView options ==
[Spec](https://drafts.csswg.org/cssom-view/#dom-element-scrollintoview)

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:

```javascript
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.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3744 using your GitHub account
Received on Tuesday, 19 March 2019 12:18:50 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:45 UTC