nDmitry / grunt-autoprefixer

Parse CSS and add vendor-prefixed CSS properties using the Can I Use database. Based on Autoprefixer.
MIT License
795 stars 60 forks source link

Does "browsers" setting work correctly for @keyframes? #81

Closed alundiak closed 9 years ago

alundiak commented 9 years ago

Based on "browsers" setting I expect to have different code (@-o-keyframes, @-moz-keyframes, @-ie-keyframes), but autoprefixer v2.0.0 fails to deliver it, and delivers only @-webkit-keyframes or just standard @keyframes.

I have this settings:

browsers: [
'last 2 Explorer versions', 'last 2 Firefox versions', 
'last 2 Opera versions', 'last 2 Chrome versions'
]

or this

browsers: ['last 2 Firefox versions', 'last 2 Opera versions']

or even this (which I expect to generate all possible variants)

browsers: ['last 2 versions']

but as result I have only:

@-webkit-keyframes XYX {
....
}

When no settings provided - default "browsers", I have only my @keyframnes and nothing new, despite default is this:

> 1%, last 2 versions, Firefox ESR, Opera 12.1

I would appreciate any kind of help.

nDmitry commented 9 years ago

The option works correctly.

http://caniuse.com/#search=keyframes

Firefox doesn't need the prefix for keyframes since 16, IE since 10 (and there was no support for CSS3 animations before 10), the last Opera on Presto, which is 12.1, also got animations unprefixed. All others including Opera on Blink need -webkit prefix.

alundiak commented 9 years ago

I mean not keyframes itself, but autoprefixer to parse keyframes and replace by custom XYZ-keyframes.

alundiak commented 9 years ago

Ok @nDmitry your comment explains everything. Tnx.

TheDutchCoder commented 9 years ago

The only problem I'm having with keyframes is that it adds prefixed items where they're not needed.

Example:

@-webkit-keyframes string {
  0%, 100% {
    -webkit-transform: translateY(0);
            transform: translateY(0);
  }
  50% {
    -webkit-transform: translateY(20px);
            transform: translateY(20px);
  }
}

@keyframes string {
  0%, 100% {
    -webkit-transform: translateY(0);
            transform: translateY(0);
  }
  50% {
    -webkit-transform: translateY(20px);
            transform: translateY(20px);
  }
}

You don't need the prefixed values in the @keyframes and the unprefixed values in the @-webkit-keyframes. Small thing but would be good to optimize.

nDmitry commented 9 years ago

You do need prefixed values in the @-webkit-keyframes. E.g. Chrome supports unprefixed CSS tranforms, but not animations.