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

[css-anchor-position] custom @position-try should allow transform-origin and translate #11666

Open
o-t-w opened this issue Feb 6, 2025 · 1 comment

Comments

@o-t-w
Copy link

o-t-w commented Feb 6, 2025

When adding animations to elements making use of anchor positioning, it would be useful to be able to change the transform-origin and translate depending on the position of the anchor. This would be possible if a custom @position-try could include the transform-origin property.

This Codepen demonstrates the sort of effects developers may want to achieve that are dependent on transform-origin being set in the appropriate place. Here's an example of how broken the animation looks when flip-block repositions the popover.

An example of using tranlate: the following transition works well when a dropdown is shown below the button that opens it, but would look strange if the dropdown is above the button.

[popover]:popover-open {
  opacity: 1;
  translate: 0 0;
  transition: opacity .2s, translate .25s, display .25s allow-discrete, overlay .25s allow-discrete;
}

@starting-style {
  [popover]:popover-open {
    opacity: 0;
    translate: 0 -4px;
  }
}

I wanted it to look like the anchored popover was literally dropping down from the button, which only makes sense if it is below the button.

@o-t-w o-t-w changed the title [css-anchor-position] custom @position-try should allow [css-anchor-position] custom @position-try should allow transform-origin Feb 6, 2025
@o-t-w o-t-w changed the title [css-anchor-position] custom @position-try should allow transform-origin [css-anchor-position] custom @position-try should allow transform-origin and translate Feb 7, 2025
@amk221
Copy link

amk221 commented Feb 12, 2025

+1

Imagine a dropdown, that animates in a downwards fashion, when anchored beneath its target.
And therefore, it should animate upwards if being anchored above its target.

Currently this doesn't work:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants