-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-position-3] Making a stickypos in a scroller also see the viewport edges #8286
Comments
I feel like having a Feels like half the problem is that the sticky thing is too confused about what directions are meant to be scrolled by the element vs the viewport in many cases. |
Which axis an element is sticky in is already clear, from which axis it has non-auto insets in. (That is, a sticky element with only "top: 0" is clearly only vertically sticky.) |
In #7475 (comment) I pondered about making Maybe for
For that third item in the list above a extra Also, when you say viewport I think you mean the Layout Viewport but maybe – referring to @flackr’s description in #7475, option 5 – the Fixed Viewport (= Visual Viewport before zoom) would make more sense? |
I think that giving the outermost viewport special abilities could be problematic for sites which use In my ideal world sticky would be able to offset based on the nearest scroller that has scrolls in the particular axis (e.g. top/bottom find the nearest overflow-y scroller). I recognize though that the situation we have though is overflow in one axis implies overflow in the other so it's not a simple change. |
The CSS Working Group just discussed The full IRC log of that discussion<dael> TabAtkins: An issue for a good while is when people use stickypos by default it sticks to viewport. Very useful. Stays on screen<dael> TabAtkins: If you have a scrollable ancestor this stops happening. Stays in scrollport but no longer sticks to viewport. IF scrollport larger than screen you can scroll sticky thing offscreen even though intended to be always visible <flackr> q+ <dael> TabAtkins: Request is for some mech to make sure a stickypos can see viewport edges even when it's not the closest scroller. Could go further to allow arbitary scroll containers, but important things are nearest scrollport and viewport <Rossen_> ack flackr <dael> flackr: Commented on issue, think viewport is too special case. I don't know if we have ability to have overflow:clip in one postion. That oculd be workable to make this composable so you can observe scroller scrolling you and not the one clipping you <dael> TabAtkins: I don't think that solves. IN a scroller that can be scrolled vertically. You have a big table and want head to be sticky. Box of table is partially offscreen but you want thead to be sticky. Genuinely scrollable access is that thing you want to pay attention past <dael> flackr: Concern is if we special-case viewport there's still a lot of cases where doc can't use viewport <dael> TabAtkins: Agree. Hits on issue viewport has magic we can't reproduce. Talked in the past about being able to mark something as root scroller. Perhaps it's a matter of we should do that and it interacts well here <dael> flackr: That would help <dael> TabAtkins: I think you were a part of those discussion in the past, but that was years ago <dael> flackr: It certainly stalled. <dael> fantasai: Other prop in the issue was make it sticky to nearest scroller in the relevant axis. If you have only horz scroll something sticky in vertical axis sticks to next scroller up <dael> TabAtkins: I thought use case listed in root is that or by what flackr mentioned <dael> flackr: I think they are same. They could ignore nearest scroller if it desn't impact in that axis <dael> fantasai: I feel like it's more flexible. Would it make sense? <Rossen_> t-1 min <dael> flackr: Tricky bit is non-scrollable direction is treated as overflow:hidden <dael> fantasai: So can't be a scroll container <dael> flackr: Could make non-scroll overflow:clip so it's explicitly not scrollable <dael> flackr: Haven't fully thought if that works <dael> TabAtkins: I don't think anything wrong with that. Clipping in 1 axis is weird visual stuff, but not if scrollable in other axis <dael> TabAtkins: That might be it <dael> flackr: Might be good in general to say something is clipped in one axis <dael> TabAtkins: I want to do investigation, but that's a plausable approach <dael> Rossen_: TabAtkins you want to do that and bring it back? <dael> TabAtkins: Sounds good <dael> fantasai: I wasn't expecting a resolution, but good to have progress |
I want to investigate if we can use the existing 'clip' keyword for this (changing behavior) or if we need to add a new keyword that's like hidden-but-clip. |
IMHO With the narrow (relative to current desired uses) initial intent of the sticky position scheme, I'm quite interested if we could expand the features being explored by houdini's layout-api &/or animation worklet to guide this native css features design? See also #2496 |
I'd very much like to see |
Can we do something like
|
I would rather have a solution that is more generic that doesn't limit to just
|
For cases where the sticky axis and the overflow axis are different, I would like a "just works" approach, so that there is no burden of knowledge here, and it is automatically set to viewport. Where the axis agrees, I like this solution, and the general keyword that can be reused in other cases. |
This problem arose many years ago and as of today, there is still no native solution available to fix it. I believe that prioritizing generalization and reusability can be achieved afterward. Like when replacing "grid-gap" with "gap". When it comes to addressing the problem of sticky parents, I believe a simple solution should be considered. I spent several hours searching for a way to make "position: sticky" work within an "[ overflow | overflow-x | overflow-y ] : [ auto | hidden | scroll ]" parent. In my experience, when people are looking to accomplish a specific task, they will search for documentation or tutorials that can guide them. If a new CSS feature becomes available, someone is likely to write a tutorial on how to use it. |
Here's a crazy random thought, what about creating a new prop which targets the scrolling container and tells it how to treat descendant sticky elements. For example; Here's some old example boilerplate first so everyone is on the same page.
My thought was if we create a new prop (name is example only) like
It's not as nice as targeted sticky behaviour, however this allows the default sticky behaviour to function as is, but allow developers the ability to declare how their scrollable containers affect descendant sticky elements. |
Could this be handled by Another related thing that could potentially cover this: #8905 — if we could extend the anchor positioning to the sticky positioning (and somehow make it possible to attach things to the specific scrollports from it, compared to the elements), then we could choose a different element and not the closest scrollpost for this. |
A "just works" solution (that sticks to nearest scroller only in the relevant axis) will break existing usage. Imagine a container component that has a max height, and will show a scrollbar in y axis if its content exceeds that height. So it may or may not scroll in the y axis. And the container has a sticky child with So a new syntax seems necessary, and +1 to |
CMIIW but I believe the only cases where this is true is when you have an element that is sticky to the top or bottom in an overflow-y container; or to the left or right in an overflow-x container. So in the case of opposite-axis position/overflow, "just works" should work. In the case of agreeing-axis position/overflow, |
Across multiple issues (and especially in #865), a persistent complaint from authors seems to be that if a stickypos element has a scrolling ancestor, it will no longer stick to the viewport edges.
For example, a table that wants sticky headers, but is wide and thus wants to be horizontally scrollable, can't be done - the headers only care about sticking in the table's own scroller, which doesn't even scroll in the vertical axis.
(See #865 (comment) from @valtlai for an example and demo.)
Even if we can't care about arbitrary ancestor scroll containers, the special case of caring about the outermost viewport seems high-value to address.
Can we consider doing this either always, or through a new keyword?
The text was updated successfully, but these errors were encountered: