[csswg-drafts] [css-scroll-anchoring-1] add API to expose current scroll anchor and offset (#6225)

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

== [css-scroll-anchoring-1] add API to expose current scroll anchor and offset ==
Absolute scroll offsets are still commonplace in many implementations of scroll restoration. If current scroll anchor nodes could be exposed via some API it would enable engineers to build more reliable scroll restoration. 

For example, we recently ran into some complications with scroll restoration on facebook.com when using `content-visibility: auto` on posts in feed. After clicking on a photo in feed and then later returning to feed, our existing scroll restoration tries to scroll to a stored absolute scroll offset, but with `content-visibility: auto` (unless `contain-intrinsic-size` is properly set) the content has not been laid out, and the browser will fail to scroll to a proper position. If we were able to store the feed's scroll anchor and an offset from it, we could use a combination of `scrollIntoView` and `scroll-margin-top` to return to a more appropriate scroll position. This would also avoid other issues with scroll restoration via an absolute offset, like incorrect scroll restoration after viewport resize. 

https://drafts.csswg.org/css-scroll-anchoring/

Upon investigating the idea further, I noticed a similar idea is mentioned in the scroll anchoring explainer doc (https://github.com/WICG/ScrollAnchoring/blob/master/explainer.md#history-scroll-restoration).

cc: @chrishtr, @vmpstr, @flackr  

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


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

Received on Monday, 19 April 2021 21:48:03 UTC