-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Keyframe mixin #1640
Comments
This is the best I could get last time I tried something like this: https://github.com/jking90/zen-garden/blob/master/styles/common/animation.less |
That is what I have now :) But using that you are still repeating yourself. |
Since it's not really an issue, stackoverflow.com would be a better place to ask a question like this (I.e. "How-To"). Though honestly speaking I suspect further disscusion will reveal certain |
Well, Stack Overflow would be fine, but I think this has something to do with how LESS parses variables. |
OK, so here's simple answer: neither |
Okay, here is the follow-up question: why not? Is there a technical reason? |
There're two distinct problems:
|
Hello, I wrote this keyframes/animation less mixin lately, if you're intrested it's here https://github.com/kuus/animate-me.less |
There are issues for allowing mixins to accept blocks, which is for this |
You can also use my solution to generate CSS keyframes with LESS: https://github.com/thybzi/keyframes |
So, speaking of keyframes... What name interpolation syntax we would choose?
|
It should.
They should. It was once arbitrary that variables only correctly evaluated when used for property values. Then they were expanded to selector names, properties, and mixins. There's no reason why variable replacement could / should not work anywhere in your statement, and the fact that it doesn't is IMO what's causing this pile of block inclusion workarounds and ongoing submitted issues. See #1648 (plus the ones you listed). |
But not nesessary that way. |
I'm just pointing out that we're interpreting variables in literally every other place within a declaration except for this one case, so it's now a case of an arbitrary omission. I agree that this is not desirable: |
This is the syntax I've been thinking about a while to solve this and other issues. .keyframes(@name) {
@-webkit-keyframes @name {
@content;
}
@keyframes @name {
@content;
}
}
:wrap-with(.keyframes("opac-change")) {
from { opacity: 1; }
to { opacity: 0; }
} |
one upside is that from a library perspective it is backwards compatible. only when a wrapped mixin is called would you need to know it was special. |
see #1859 |
See less/less.js#1640 for more info about LESS loop support for @kayframes
hi! .keyframe(@name, @roules) { @-webkit-keyframes @name { @roules(); } @-moz-keyframes @name { @roules(); } @-ms-keyframes @name { @roules(); } @-o-keyframes @name { @roules(); } @keyframes @name { @roules(); } } if i import this file normally (@import 'animaton.less') all works well, but if i set the import as reference (@import (reference) 'animaton.less') my uses of the mixin doesn't work! |
It's more like "something that was not considered when |
yeah, it's a feature request |
I'm trying to create a keyframes mixin for my framework. But it's not working for a number of reasons.
What I'm trying to achieve is write somethig like this:
And get something like this:
So I wrote this bit of LESS:
And those who know the inner workings of LESS probably see a lot wrong here, first of all @-webkit-keyframes and @Keyframes are never defined.
@name is, but is not used for some reason, probably because it crashes on @Keyframes. A stand alone variable like @animation doesn't work either.
Is this at all possible?
The text was updated successfully, but these errors were encountered: