Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Created February 29, 2012 19:29
Show Gist options
  • Save chriseppstein/1943798 to your computer and use it in GitHub Desktop.
Save chriseppstein/1943798 to your computer and use it in GitHub Desktop.
This is code that runs using Sass 3.2 prerelease and something like this will be in compass soon.
@include keyframes(appear-and-roundify) {
0% { opacity: 0; @include border-radius(2px); }
100% { opacity: 1; @include border-radius(10px); }
}
@-moz-keyframes appear-and-roundify { 0% { opacity: 0; -moz-border-radius: 2px; border-radius: 2px; }
100% { opacity: 1; -moz-border-radius: 10px; border-radius: 10px; } }
@-webkit-keyframes appear-and-roundify { 0% { opacity: 0; -webkit-border-radius: 2px; border-radius: 2px; }
100% { opacity: 1; -webkit-border-radius: 10px; border-radius: 10px; } }
@-o-keyframes appear-and-roundify { 0% { opacity: 0; -o-border-radius: 2px; border-radius: 2px; }
100% { opacity: 1; -o-border-radius: 10px; border-radius: 10px; } }
@-ms-keyframes appear-and-roundify { 0% { opacity: 0; -ms-border-radius: 2px; border-radius: 2px; }
100% { opacity: 1; -ms-border-radius: 10px; border-radius: 10px; } }
@keyframes appear-and-roundify { 0% { opacity: 0; border-radius: 2px; }
100% { opacity: 1; border-radius: 10px; } }
@mixin keyframes($name,
$moz: $experimental-support-for-mozilla,
$webkit: $experimental-support-for-webkit,
$o: $experimental-support-for-opera,
$ms: $experimental-support-for-microsoft,
$khtml: $experimental-support-for-khtml,
$official: true)
{
@if $moz {
@include with-only-support-for($moz: true) {
@-moz-keyframes #{$name} { @content; }
}
}
@if $webkit {
@include with-only-support-for($webkit: true) {
@-webkit-keyframes #{$name} { @content; }
}
}
@if $o {
@include with-only-support-for($o: true) {
@-o-keyframes #{$name} { @content; }
}
}
@if $ms {
@include with-only-support-for($ms: true) {
@-ms-keyframes #{$name} { @content; }
}
}
@if $khtml {
@include with-only-support-for($khtml: true) {
@-khtml-keyframes #{$name} { @content; }
}
}
@if $official {
@include with-only-support-for {
@keyframes #{$name} { @content; }
}
}
}
@mixin set-experimental-support($moz: false, $webkit: false, $ms: false, $o: false, $khtml: false) {
$experimental-support-for-mozilla: $moz;
$experimental-support-for-webkit: $webkit;
$experimental-support-for-microsoft: $ms;
$experimental-support-for-opera: $o;
$experimental-support-for-khtml: $khtml;
}
@mixin with-only-support-for($moz: false, $webkit: false, $ms: false, $o: false, $khtml: false) {
// Capture the current state
$original-moz: $experimental-support-for-mozilla;
$original-webkit: $experimental-support-for-webkit;
$original-o: $experimental-support-for-opera;
$original-ms: $experimental-support-for-microsoft;
$original-khtml: $experimental-support-for-khtml;
@include set-experimental-support($moz, $webkit, $ms, $o, $khtml);
@content;
@include set-experimental-support($original-moz, $original-webkit, $original-ms, $original-o, $original-khtml);
}
@redoPop
Copy link

redoPop commented Jun 12, 2013

@neekey Compass' documentation covers the latest stable version (0.12.2) whereas this feature is for 0.13, which is currently in alpha. Animations will be added to Compass and documented when 0.13 becomes the latest stable version. You can keep up-to-date with new versions of Compass here:

http://rubygems.org/gems/compass/versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment