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

duplicate @keyframes generated in CSS #5

Open
xmlking opened this issue Aug 3, 2014 · 5 comments
Open

duplicate @keyframes generated in CSS #5

xmlking opened this issue Aug 3, 2014 · 5 comments

Comments

@xmlking
Copy link

xmlking commented Aug 3, 2014

This SCSS code producing duplicate @keyframes bounceOut { keyframes in generated CSS.

.sumo1 {
  @include bounceOut($duration: 1s);
}
.sumo2{
  @include bounceOut($duration: 2s);
}

how to avoid duplicate keyframes?

@josephfusco
Copy link

Was the duplicate keyframe issue ever solved? I've been trying to find a solution myself but it doesn't seem possible yet.

@xmlking
Copy link
Author

xmlking commented Aug 25, 2014

No solution yet. Still researching ....

@josephfusco
Copy link

I don't think it is possible at the current state of scss. The only resolution I've come up with would be to set the animation at the root instead of nested as a property per each item. This would require a lot of restructering but would look something like this.

//take classes and IDs as arguments
@mixin bounceIn($class){
  #{$class}{
     //set animation
  }
  @keyframes BounceIn{
     //keyframe stuff
  }
}

//set animation once at root of file to include all objects we want with bounceIn
@include bounceIn($class: ".objectA, .objectB, #thisToo");

//do styling on each object without the animation since it's being declared globally
.objectA{
    color:blue;
    //normal styles
}
.objectB{
    color:red;
    //normal styles
}
#thisToo{
    padding:10px 30px;
    //normal styles
}

@bpongy
Copy link

bpongy commented Oct 24, 2016

It's possible with unique-id() sass function.
http://sass-lang.com/documentation/Sass/Script/Functions.html#unique_id-instance_method

example:

$unique_id: unique-id();
animation: wobble_#{$unique_id} ....
....
@Keyframes wobble_#{$unique_id} {
....

@romulof
Copy link

romulof commented Dec 28, 2016

cssnano doesn't clean this up?

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

4 participants