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

The particular scenario mentioned by @CyberAP can be solved as follow:

**CSS:**
`html { scroll-behavior: smooth; }`

**JS:**
```
element.scrollIntoView(..params);
element.focus({preventScroll:true});
```

Without the preventScroll parameter, you are subject to browser quirks as below:

**Firefox**
Scrolls to the correct position (meaning, element.scrollIntoView) yet abandons smooth scrolling, even though the browser supports it. Not great, but at least the scroll position is correct.

**Safari/webkit**
Same as Firefox yet would not scroll smoothly in any case, as it's not supported. Not great, but at least the scroll position is correct.

**Chrome**
Chrome is the big offender here. It seems to cancel the scrollIntoView action altogether, instead does the smooth scroll from element.focus(), CSS based, and scroll position logic is based on that. In practice, this often means a wrong scroll position.

**Other scenarios**
Whilst preventScroll solves this particular scenario, I still very much agree we need a callback. If you need to do anything else after scrolling completes (say, run an animation), there's no robust way to do that right now. 

-- 
GitHub Notification of comment by fchristant
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3744#issuecomment-685683932 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 2 September 2020 11:58:54 UTC