[csswg-drafts] [cssom-view] Consider making scroll methods return promises

mkay581 has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-view] Consider making scroll methods return promises ==
[Smooth scrolling](https://drafts.csswg.org/cssom-view/#smooth-scrolling) has been introduced into the spec where the scroll happens over a period of time, which is great. However, I think it would be even more useful if scroll method returned a promise so the developer could wait until the scroll finishes before moving on to next set of tasks. 

Obviously `scroll()`ing on an element where `scroll-behavior` option set to `auto` makes scroll instant and is therefore not inherently asynchronous. But I think, to keep the API consistent, the scroll method should return a promise every time it is used.

So if you had the following HTML...

```html
<div id="scroll-container" style="scroll-behavior: smooth;">
   <!-- other content here --> 
</div>
```

you can do things like this:

```js
element.scroll(0, 400).then(() => {
   // ...scroll has finished
});
```


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1562 using your GitHub account

Received on Sunday, 25 June 2017 14:33:01 UTC