-
Notifications
You must be signed in to change notification settings - Fork 676
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-transforms][css-logical] Flow-relative Transforms #1544
Comments
This is a great idea. While I can think of use-cases where the flow is irrelevant to a transform, I can think of many other cases where transforms are used similarly to relative positioning, and would absolutely be flow-dependent. I think most of the X/Y transforms could be adapted pretty cleanly from an author perspective: |
To follow up: would there then be a I think most authors wouldn't mind using the "longhand" by defining each transform logically if it helps keep the code easy to understand, but some might like the convenience they find in Or flip it on its head and use a |
I have an app, SVGcode that has an LTR and an RTL layout with hoverable elements that scale up from the corner to the middle at the logical start and end of the inset inline and the inset block. A reduced reproduction case can be found in this demo on Glitch (hover over the avatar). While I can position the images logically via the CSS below (disregard that this could be achieved with margin as well)… img {
position: absolute;
inset-inline-start: 10px;
inset-block-start: 10px;
} …I have to hand-code the [dir=ltr] img {
transform-origin: top left;
}
[dir=rtl] img {
transform-origin: top right;
} Would it be feasible to make img {
position: absolute;
inset-inline-start: 10px;
inset-block-start: 10px;
transform-origin: block-start inline-end; /* Doesn't currently work */
} Or maybe I'm overlooking something, in this case sorry for the noise and thanks for a pointer where I could read up upon the current solution. (Migrated from #7051.) |
Having similar issues now that I have changed most of my code to :root {
--transform-inline: translateX(100%);
}
:root[dir=rtl] {
--transform-inline: translateX(-100%);
}
.element {
transform: var(--transform-inline);
} I personally like the |
I've encountered this and for now I've used a workaround similar to @clshortfuse's (by reading the direction and passing it as a prop to the styled component), but I hope in the future we'll have logical transform properties and values too. |
Yes, there are some cases where we would really need this, I'm facing one right now for a custom toggle (using transforms for smooth animations): I'm doing:
for active state. I have to do:
To get the proper display: Something like:
And same for For Migrated from #1788 |
Does anyone involved with the standardisation process know how this could be taken forward? It’s surprising to me that this issue has been opened for so long, and also heartening to see so much recent activity. With browser support for logical properties and values getting pretty good, I can only imagine lots more people will start to be looking for this for transforms too. Sharing my personal flavour of a workaround in case it helps – essentially using the same technique as for icons mirroring: :root {
--flow-direction: 1;
}
[dir="rtl"] {
--flow-direction: -1;
}
.classname {
transform: translateX(calc(var(--flow-direction) * 100%));
} Bit verbose but makes it possible to use this |
See also #7646 (comment) wrt logical longhands. |
https://lists.w3.org/Archives/Public/www-style/2015Jan/0209.html
Transforms always operate on physically-oriented coords. Should it be possible to have logical transforms? If so, how?
The text was updated successfully, but these errors were encountered: