Skip to content

Accept transform-origin inside @position-try #12169

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

Open
Zhang-Junzhi opened this issue May 7, 2025 · 0 comments
Open

Accept transform-origin inside @position-try #12169

Zhang-Junzhi opened this issue May 7, 2025 · 0 comments

Comments

@Zhang-Junzhi
Copy link
Contributor

When implementing a pop-over with anchor positioning, a common pattern is to animate its appearance using transforms (e.g., scaling or rotating). In such cases, it’s often desirable to set the transform origin at the vertex closest to the anchor point. Example:

.some-popover-ele
{
    display: none;
    opacity: 0;
    transform: scale(.97);
    transition: transform .2s, opacity .2s, display .2s allow-discrete, overlay .2s allow-discrete;
    position: absolute;
    top: calc(anchor(bottom) + 5px);
    left: anchor(left);
    transform-origin: top left;
    position-try: --popover-from-top-left, --popover-from-bottom-right, --popover-from-top-right;
}

.some-popover-ele:popover-open
{
    display: block;
    opacity: 1;
    transform: none;
    @starting-style
    {
        opacity: 0;
        transform: scale(.97);
    }
}

@position-try --popover-from-top-left
{
    top: auto;
    bottom: calc(anchor(top) + 5px);
    transform-origin: bottom left;
}

@position-try --popover-from-bottom-right
{
    left: auto;
    right: anchor(right);
    transform-origin: top right;
}

@position-try --popover-from-top-right
{
    left: auto;
    right: anchor(right);
    top: auto;
    bottom: calc(anchor(top) + 5px);
    transform-origin: bottom right;
}

Unfortunately, transform-origin is currently not allowed within @position-try. Therefore, I propose adding support for transform-origin in this context.

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

1 participant