Open johannesodland opened 1 year ago
Could be worth keeping #3322 in mind here.
Some more discussion in https://github.com/w3c/csswg-drafts/issues/8400, which is closed as a duplicate.
The CSS Working Group just discussed [css-overflow] add method to prevent elements from contributing to scrollable overflow
, and agreed to the following:
RESOLVED: Adopt this feature as overflow-bikeshed
overflow-transform: clip
overflow-clip-transform: contain
transform-clip: overflow
Some more naming possibilities (some of which are from or partly from the discussion above; I didn't see any in #8400) include (listing the initial value first):
One thing that I've heard from developers is a desire just to skip the transform adjustment that happens. E.g. something that could be useful is:
overflow-contribution: normal | none | ignore-transform
(see also #9458 about defining exactly what transform adjustment happens!)
One thing that I've heard from developers is a desire just to skip the transform adjustment that happens. E.g. something that could be useful is:
overflow-contribution: normal | none | ignore-transform
If this is about elements being moved by transforms triggering overflow, it's not exclusive to transforms, it also applies to positioning.
If this property affects scrollable overflow, it should probably also affect scrolling related APIs and snap areas. E.g. I could see overflow-contribution: ignore-transform
being really useful to:
scroll-snap-align: center
element which currently can lead to jittery scroll updates.As such, maybe the name needs to be more generic like overflow-box
?
Adgenda+ to paint the bikeshed on a name for this property.
The CSS Working Group just discussed [css-overflow] add method to prevent elements from contributing to scrollable overflow
.
I think for the purpose of learnability, it would be better to have this as one property rather than two.
To summarize the discussion, there are two behaviors being discussed here:
I think we are all agreed that these are both valuable behaviors to be able to control. The main point of contention was whether this would be 1 or 2 properties. To help I'll suggest possible properties / values (of course welcome bikeshedding).
As one property, this would look something like this:
overflow-contribution: normal | ignore-transform | none;
The question is if we specify none, what are the effects on scrolling / snapping operations? Would we prevent snapping / scrolling to this element? If not, what if you want the element to not contribute to scrollable overflow and ignore transforms for scroll related operations? A counter-point to this, is when you want to not contribute to scrollable overflow, the UA won't guarantee that this element is reachable which may mean that the developer doesn't intend the user to need to scroll to this element, so maybe it would be reasonable to treat the element as purely decorative?
As two properties, these would be specified independently, e.g.:
overflow-contribution: normal | none;
scroll-align: normal | ignore-transform;
Do all combinations of this make sense? Probably, you can imagine how these could be applied independently, but are there practical use cases where we want to scroll to an element that doesn't contribute to scrollable overflow? Perhaps an overly large image that you don't want to introduce horizontal scrolling for?
Alternately, a third option could be to have a single property with multiple values, but this may just suggest a need for multiple longhand properties, e.g.
overflow-contribution: <normal | none> || <auto | ignore-transform>?;
The question is if we specify none, what are the effects on scrolling / snapping operations? Would we prevent snapping / scrolling to this element?
Could we treat this similar to an element that is placed wholly or partly into the negative scrollable overflow region? Such an element won't extend the scrollable overflow area, and the used snap point for the element is the position resulting from scrolling as much as possible towards the desired snap point in the relevant axis?
Regarding snapping operations: there is a related issue https://github.com/w3c/csswg-drafts/issues/7885 containing use cases for extending the scrollable overflow area to make snap points reachable. Maybe that issue could be solved with the same property/-ies?
https://www.w3.org/TR/2022/WD-css-overflow-3-20221231/#scrollable
Motivation
Sometimes it's useful to prevent elements from contributing to the scrollable overflow area. In particular elements that exist for purely decorative purposes. This could i.e. be elements that are animated in the background with 2d or 3d transforms.
For elements not participating in a 3D rendering context its possible to eliminate them from contributing to the scrollable overflow area by adding
contain: paint
,overflow: hidden
oroverflow: clip
to a parent, effectively clipping them away.This is not a workable strategy for elements participating in a 3D rendering context.
contain: paint
,overflow: hidden
andoverflow: clip
are all grouping property values, and will force the parent element to have a used style offlat
forpreserve-3d
. This effectively separates the elements from the 3d rendering context they were participating in.Proposal
Add a method to prevent elements from contributing to scrollable overflow. This could be a new property such as
overflow-contribution: normal | none
.Alternative solutions
Allow a way of clipping overflow that is not a grouping property value and does not force a used style of
flat
forpreserve-3d
.It seems like there's no interop on
contain: paint
forcing used style offlat
forpreserve-3d
. WebKit does forceflat
, while Blink and Gecko does not seem to forceflat
at the moment.An alternative solution would be remove
contain: paint
from the grouping property values.Example