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

> happy to see the event is solving the problem so elegantly!

Considering that the aim of scrollIntoView() is to bring something into view, triggering events may not be the most elegant solution. It might be the easiest to implement in browsers, but it will require significantly more JavaScript code to handle the edge cases.

There are at least two edge cases that make this solution less practical:

* As you mentioned, scrollIntoView() may not move if scrolling is not possible or if the element is already in view. While we can write JavaScript code to address this, it adds complexity.
* Scrolling might start, but if the user intervenes by stopping or changing the scroll position, the event may fire when scrollIntoView() did not achieve its intended effect. Again, handling this with JavaScript adds complexity.

Returning a promise that either fulfills or rejects would eliminate the need for additional JavaScript code to handle these cases, making it a more elegant solution overall.


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


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

Received on Tuesday, 6 August 2024 07:02:04 UTC