Add scroll-promises examples#386
Conversation
|
@hamishwillee darnit, adding the usage of the To fix this up, I've added a feature detection function and used that to register different event handlers depending on whether the browser supports the promise-returning scroll functions. I'm then intending to just add a note about the feature detection in the articles, but I thought I'd ask your opinion first. I'd rather do it this way to avoid making the event handler explanation any more complicated in the articles. |
|
I think that makes sense. |
pepelsbey
left a comment
There was a problem hiding this comment.
Looks good! Thank you 🙂
Just a few suggestions for readmes and titles.
Co-authored-by: Vadim Makeev <hi@pepelsbey.dev>
Co-authored-by: Vadim Makeev <hi@pepelsbey.dev>
Co-authored-by: Vadim Makeev <hi@pepelsbey.dev>
Super, ta! |

In Chrome 150 onwards, the standard
ElementandWindowscroll methods now return promises. See https://chromestatus.com/feature/5082138340491264. This is particularly useful when a scroll operation is not instantaneous (e.g. you've gotscroll-behavior: smooth;set on the scrolling container), and you want to programmatically react to the scroll operation finishing, for example, by updating the UI.Affected methods are:
Element.scroll()Element.scrollBy()Element.scrollIntoView()Element.scrollTo()Window.scroll()Window.scrollBy()Window.scrollTo()This PR adds a couple of demos that show each promise-returning scroll method in use. I could do these as live examples, but I decided not to, as I don't want to add a huge standalone live example to all seven pages, with all of them doing nearly the same thing. I'd rather provide a couple of code snippets on each page and then link to the full example.