w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.36k stars 641 forks source link

[css-anchor-position] Should scroll-margin/padding have an effect on position-visibility: anchors-visible? #10410

Open kizu opened 1 month ago

kizu commented 1 month ago

Was playing with the position-visibility: anchors-visible (https://drafts.csswg.org/css-anchor-position-1/#position-visibility), and I think it might be useful to take the scrollable area's scroll-padding or the anchor's scroll-margin into consideration (https://drafts.csswg.org/css-scroll-snap/#propdef-scroll-padding). An example: https://codepen.io/kizu/pen/BaedPEB

https://github.com/w3c/csswg-drafts/assets/177485/378c29d2-6785-477a-8f2f-13f5be9f265c

Here we can see how if we have some fixed element reducing the effective visible area of our scrollable container, we'd want to consider it for the position-visibility. Hooking it onto scroll-margin and scroll-padding sounds logical, as this is very similar to other similar cases like scrolling or snapping to the targeted element.

johannesodland commented 1 month ago

Yeah, that would be useful in a lot of cases.

It might be smart to do something similar to Scroll-driven Animations, where view-timeline-inset: auto is specced to use the values of scroll-padding while it is still possible to specify a custom length-percentage value.