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

0% steps in @keyframe animations incorrectly changed to 0 #80

Open
matthewrobb opened this issue May 18, 2013 · 25 comments
Open

0% steps in @keyframe animations incorrectly changed to 0 #80

matthewrobb opened this issue May 18, 2013 · 25 comments
Assignees
Labels

Comments

@matthewrobb
Copy link

Taking the following CSS:

@keyframe anim {
    0% { opacity: 0; }
  100% { opacity: 1; }
}

The output will be incorrectly rewritten to:

@keyframe anim {
    0 { opacity: 0; }
 100% { opacity: 1; }
}

This is not functionally equivalent.

@tml
Copy link
Contributor

tml commented May 20, 2013

Would

@keyframe anim{0%{opacity:0}100%{opacity:1}}

be equivalent?

@ghost ghost assigned tml May 20, 2013
@matthewrobb
Copy link
Author

@tml Yeah that would work perfectly.

@brianwozeniak
Copy link

Your fix only resolves @Keyframes, however, remember that there are many others such as:

@-moz-keyframes
@-webkit-keyframes
@-o-keyframes

This will work better:

css = css.replaceAll("(@(?:-.+?)?keyframe.*?)0{", "$10%{");

brianwozeniak pushed a commit to brianwozeniak/yuicompressor that referenced this issue Aug 16, 2013
brianwozeniak pushed a commit to brianwozeniak/yuicompressor that referenced this issue Aug 16, 2013
@tml
Copy link
Contributor

tml commented Aug 16, 2013

👍 Thanks, @Bigwebmaster; I didn't consider vendor-specific extensions.

@a701440
Copy link

a701440 commented Oct 29, 2013

It is also stripping "deg" unit from "0deg".

/*! Before minification */
@-webkit-keyframes spin {
0% {
-webkit-transform: rotateZ(0deg);
}

100% {
    -webkit-transform: rotateZ(360deg);
}

}

/*! After minification */
@-webkit-keyframes spin{0{-webkit-transform:rotateZ(0)}100%{-webkit-transform:rotateZ(360deg)}}

@leods92
Copy link

leods92 commented Jan 13, 2014

I have just downgraded to the previous version that didn't have this bug.
Does anyone know when this bug fix will be released? I think it's very important given that people are using animations more often these days.

@kaansoral
Copy link

+1 @leods92 - this issue breaks the following css rule at mobile webkit browsers

@sarim
Copy link

sarim commented Mar 26, 2014

The pull requests here don't solve the issue. It works if you have 0% { ........ } but fails if there is a comma, Ex:

@-webkit-keyframes circlebounce {
    0%, 100% { -webkit-transform: scale(0.0) }
    50% { -webkit-transform: scale(1.0) }
}

sarim added a commit to sarim/AvroPad that referenced this issue Mar 26, 2014
still a forked yui required http://cl.ly/Udo9
@ardok
Copy link

ardok commented Jul 30, 2014

Does using 0.00% solve the problem?

@und3f1ned
Copy link

Solved by using 0.00% instead 0%

@ardok
Copy link

ardok commented Aug 1, 2014

@snusmubrik thanks!

@Gennady77
Copy link

I can't make sense somebody fix this bug?

@tml tml self-assigned this Apr 14, 2015
@tml
Copy link
Contributor

tml commented Apr 14, 2015

@Gennady77 This should be fixed if you use master.

@Gennady77
Copy link

I use npm chanel and there is latest version and there is the bug.

@tml
Copy link
Contributor

tml commented Apr 16, 2015

I don't know anything about how npm is choosing to bundle this, maybe you can reach out to them and ask them to join in the conversation here?

@foaly-nr1
Copy link

@tml I just built form master, same result.

@smadalin
Copy link

smadalin commented Aug 4, 2015

you can use "from" - "to" instead of 0%- 100%

@zanedev
Copy link

zanedev commented Oct 30, 2015

+1 on the from and to for now

@chinshr
Copy link

chinshr commented Dec 5, 2015

0.00% instead of 0% fixed this problem for me. Thanks!

@AngelTs
Copy link

AngelTs commented Jan 29, 2016

Use 00% instead of 0%

steven-hadfield pushed a commit to steven-hadfield/yuicompressor that referenced this issue Feb 9, 2016
@jochenberger
Copy link
Contributor

Should be fixed in master (see #231)

eps1lon added a commit to eps1lon/fwrails that referenced this issue Feb 23, 2017
eps1lon added a commit to eps1lon/fwrails that referenced this issue Feb 23, 2017
@josenobile
Copy link

I'm affected for the same.
Check https://www.w3.org/TR/css3-animations/#keyframes

Note that the percentage unit specifier must be used on percentage values. Therefore, ‘0’ is an invalid keyframe selector.

@lordrhodos
Copy link

same here, just ran into the issue trying to minify the spectre css files which have the following code:

// Animations
@keyframes loading {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes slide-down {
  0% {
    transform: translateY(-3rem);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

using yuicompressor 2.4.8

@1337GameDev
Copy link

I was able to fix this issue by doing the following:

  1. Removed all keyframe platform specific selectors (webkit-/mox-/ie-)
  2. Used the following paradigm for degrees and percentages:
@keyframes spin {
  00% {
    transform: rotate(-1deg);
  }
  100.00% {
    transform: rotate(-361deg);
  }
}

.spinner {
  animation: spin 2.00s linear infinite;
}

This prevents 0%/100% from having the "%" removed, as well as the "deg" being removed.
Using the "animation" selector also had "s" removed from seconds, so I had to add a 0 after.

These issues really should be fixed. I shouldn't have to fight with a minifier.

This minifier has also been officially adopted by PHPWebstorm (which I use for work). The minifier was installed using NPM via command-line. NPM's version should be verified to be using the MASTER version so fixes of this nature are included.

@gaeld
Copy link

gaeld commented Feb 7, 2018

The previously workaround do work, but they are working. Using CSS animations librairies is a nightmare, because you have to rewrite every-rules.
Any news on a fix yet ?

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

Successfully merging a pull request may close this issue.