Re: [csswg-drafts] [css-anchor-position] Better handling of scroll position for fixpos elements on first layout (#10999)

I'm not convinced that an anchor recalculation point at fallback position change is going to work too well.

```html
<!DOCTYPE html>
<div style="height:100px;"></div>
<div style="width:100px; height:200px; anchor-name:--tjor; background:cyan;"></div>
<div id="elm" style="position:absolute; position-anchor:--tjor; position-area:top; position-try-fallbacks:flip-block; width:50px; height:100%; box-sizing:border-box; border:solid; background:hotpink;"></div>
<div style="height:200vh;"></div>
```

The height of the positioned element `#elm`, which should be anchored above (first option) or below (second option) the anchor, is 100%. It's naturally going to fit above initially. Now, if we scroll down a few pixels, it's no longer going to fit above, and we'll place it below. If there really is an anchor recalculation point at that point, we're going to recalculate based on the new scroll offset, so that `#elm` will fit snugly below the anchor. By doing that, `#elm` is also going to fit snugly above the anchor again, and we'll place it there (it's the first option, after all, and it fits!), at its new shrunken size.

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


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

Received on Friday, 29 November 2024 07:56:07 UTC