Re: [csswg-drafts] [css-anchor-position-1] Interaction with `anchor-center` and scrolling (#9223)

> How exactly do Outside I and Outside II work?

I assume Outside 1 is "distance between center of anchor and further side of the containing block, then the same distance to the other side".  Dunno what the Outside II is, tho I don't think Ian is proposing anything about it.

> Are we going to use different IMCB algorithms when anchor is initially inside vs. outside the containing block, and vs. those partially in CB? And if so, if the element can be scrolled back into CB, does the IMCB algorithm change based on the scroll offset?

It sounds like that's what Ian is suggesting, yes. That does mean a (relatively minor) jump as the anchor falls completely outside of the CB - the abspos stops sliding to stay in the CB and instead jumps back to following the anchor.

But hm, I think I'd prefer to just extend the "sliding" behavior if possible, to let it slide out of the CB when the anchor goes out:

1. If possible, center the abspos over the anchor, except:
2. If centering would cause the abspos to overflow its IMCB, instead slide it off-center to keep it in the IMCB, except:
3. If the anchor is smaller than the abspos, then as the anchor's far edge leaves the IMCB, align the abspos's same edge with it. (As it *starts to* leave, it pulls the abspos with it.)
4. If the anchor is larger than the abspos, then as the anchor's near edge leaves the IMCB, align the abspos's same edge with it. (As it *finishes* leaving, it pulls the abspos with it.)

This avoids jumps - each of the three modes smoothly picks up where the previous left off. This also keeps the abspos and anchor near each other even when the anchor is way off-screen, so you don't have the abspos accidentally hanging around on-screen.

(That said, this sort of "be sticky to the anchor" behavior might be useful more generally; off-line discussion with @xiaochengh suggests that it is. I'll chat with them more about that and see if it's reasonable to make the sliding/sticking a more general feature that'll apply to more cases than just anchor-center, in which case we can simplify anchor-center to just be "always center", no built-in overflow avoidance.)

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9223#issuecomment-1721286130 using your GitHub account


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

Received on Friday, 15 September 2023 13:29:30 UTC