In CSS Conditional 5, we've added the ability to query the scroll-state of a container with container-type: scroll-state, which allows children to use queries like scrollable(bottom) to see if there's scrollable content being hidden by the bottom edge of the scrollport.
When I was making edits to support single-axis scrollers, I made the assumption that non-scroll containers would simply ignore being declared a scroll-state container, so you could query horizontal scrolling and get the answer from the nearest horizontally scrollable container, and query vertical scrolling and get the answer from the nearest vertically scrollable container. I assumed this is how things already worked for non-scrollers, but that's not the case; the spec makes it clear that if an element uses container-type: scroll-state but isn't a scroll container, the queries just evaluate to unknown. (This is consistent with making yourself a size query container when you don't have a box, like display:contents.)
The ability to query different containers for scroll state when single-axis scrollers are in play is still useful, tho, for all the reasons single-axis scrollers are useful in the first place.
So, which approach do we want to take?
- Fix the spec so that queries against an element that's not scrollable in the relevant axis evaluate to unknown, consistent for both non-scrollers and single-axis scrollers. Add
inline-scroll-container and block-scroll-container keywords to allow an element to declare it can answer queries in just one axis.
- Change the spec so that scroll queries against an axis that isn't scrollable will skip up the ancestor tree until it finds a query container that can answer the question. Do the same to size queries, for consistency.
@lilles tells me in private chat that option 2 is complicated, but I'm still working through understanding the reasons that is the case.
In CSS Conditional 5, we've added the ability to query the scroll-state of a container with
container-type: scroll-state, which allows children to use queries likescrollable(bottom)to see if there's scrollable content being hidden by the bottom edge of the scrollport.When I was making edits to support single-axis scrollers, I made the assumption that non-scroll containers would simply ignore being declared a scroll-state container, so you could query horizontal scrolling and get the answer from the nearest horizontally scrollable container, and query vertical scrolling and get the answer from the nearest vertically scrollable container. I assumed this is how things already worked for non-scrollers, but that's not the case; the spec makes it clear that if an element uses
container-type: scroll-statebut isn't a scroll container, the queries just evaluate to unknown. (This is consistent with making yourself a size query container when you don't have a box, likedisplay:contents.)The ability to query different containers for scroll state when single-axis scrollers are in play is still useful, tho, for all the reasons single-axis scrollers are useful in the first place.
So, which approach do we want to take?
inline-scroll-containerandblock-scroll-containerkeywords to allow an element to declare it can answer queries in just one axis.@lilles tells me in private chat that option 2 is complicated, but I'm still working through understanding the reasons that is the case.