Skip to content
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

Overflow management with position-try syntax #167

Open
jh3y opened this issue Apr 10, 2024 · 5 comments · May be fixed by #202
Open

Overflow management with position-try syntax #167

jh3y opened this issue Apr 10, 2024 · 5 comments · May be fixed by #202
Assignees
Labels
α alpha anchor-position-1 Feature as specified in https://drafts.csswg.org/css-anchor-position-1
Milestone

Comments

@jh3y
Copy link

jh3y commented Apr 10, 2024

Hey 👋

Been trying the polyfill with a few demos. Any plans to support the new syntax and auto flip values?

https://drafts.csswg.org/css-anchor-position/#position-try-options

@mirisuzanne
Copy link
Member

Hi @jh3y - yes, that's the plan. We wanted to wait for the new syntax to solidify some, and I think that's mostly happened. But we could also use help from the community. Code contributions are welcome, as well as financial support (especially from companies that plan to use this in production).

@jamesnw jamesnw changed the title Plans for position-try-options? Overflow management with position-try syntax May 17, 2024
@jamesnw jamesnw added the anchor-position-1 Feature as specified in https://drafts.csswg.org/css-anchor-position-1 label May 17, 2024
@jamesnw
Copy link
Contributor

jamesnw commented May 17, 2024

@jamesnw
Copy link
Contributor

jamesnw commented Jun 21, 2024

In exploring the try-tactics in position-try-options, I'm not seeing a clear way to polyfill that behavior, and wanted to document what I'm seeing.

Adding a try-tactic, for instance flip-inline, automatically creates a position option based on a transformation of the element's specified style. flip-inline would change left: anchor(right) to right:anchor(left).

This specified style may come from anywhere in the cascade. In other places, we are getting a computed style using getComputedStyle(el), but in this case we would need, for instance left: anchor(right), whereas getComputedStyle(el) would give us left: 200px.

To implement try-tactics, we will need to find a way to get all the raw CSS rules (with the cascade resolved) for any element that matches any selector with a try-tactic specified.

@jgerigmeyer
Copy link
Member

To implement try-tactics, we will need to find a way to get all the raw CSS rules (with the cascade resolved) for any element that matches any selector with a try-tactic specified.

@jamesnw You're right, this is tricky. 🤔 What if we did something like:

  1. Add a CSS custom property to every block where we find an anchor() fn is assigned to an inset property. key: relevant inset property, value: unique uuid, e.g. --top-123: <uuid>
  2. When we find a try-tactic, loop through the elements matching that rule's selector.
  3. For each element, look for the value of --top-123. Whichever uuid matches, we know which anchor fns are applied?

@mirisuzanne I'm curious if you have ideas here.

@mirisuzanne
Copy link
Member

@jgerigmeyer @jamesnw Yeah, the custom property would have been my proposal as well. I don't have any better ideas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
α alpha anchor-position-1 Feature as specified in https://drafts.csswg.org/css-anchor-position-1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants