- From: Daniel Tonon via GitHub <sysbot+gh@w3.org>
- Date: Wed, 24 Aug 2022 11:34:33 +0000
- To: public-css-archive@w3.org
I get the feeling [the solution I mention above](https://github.com/w3c/csswg-drafts/issues/3744#issuecomment-564821823) (using a promise) is going to break backwards compatibility since `element.scrollIntoView` will go from returning a falsy value (undefined) to a truthy value (a promise). In that case, it should be safe to just add a new callback option to the options object. ```js element.scrollIntoView({ behavior: 'smooth', onComplete: (scrollEvent) => { console.log('The browser has finished scrolling'); } }); ``` Then if developers want it in promise format we can make a simple utility for it: ```js function scrollElemIntoView(elem, options) { return new Promise((resolve, reject) => { if (!elem) { reject("Cannot scroll as the target element does not exist"); return; } element.scrollIntoView({ behavior: 'smooth', onComplete: resolve, ...options }); }) } scrollElemIntoView(elem, { block: 'start' }).then( scrollEvent => { console.log('The browser has finished scrolling') }) ``` -- GitHub Notification of comment by Dan503 Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3744#issuecomment-1225596635 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 24 August 2022 11:34:35 UTC