Skip to content

Instantly share code, notes, and snippets.

@lunelson
Last active May 18, 2021 15:58
Show Gist options
  • Select an option

  • Save lunelson/1a5abecfa5823b154922 to your computer and use it in GitHub Desktop.

Select an option

Save lunelson/1a5abecfa5823b154922 to your computer and use it in GitHub Desktop.
Fork of Tomeij's Animation mixin
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
@mixin animation($args...) {
$name: unique-id(); // name for @keyframes
$args: join((), $args, 'space'); // conform args as SSV
animation: $name + ' ' + $args;
@keyframes #{$name} {
@content;
}
}
// alias of above
@mixin anim($args...) { @include animation($args...) { @content; } }
.test1 {
@include anim(0.5s ease-in) {
from { background-position: 0% 0%; }
to { background-position: 114.2857% 0%; }
}
}
.test2 {
@include anim(1s, ease-out) {
from { width: 2rem; }
to { width: 5rem; }
}
}
.test1 {
animation: urudhohfy 0.5s ease-in;
}
@keyframes urudhohfy {
from {
background-position: 0% 0%;
}
to {
background-position: 114.2857% 0%;
}
}
.test2 {
animation: urudhohg6 1s ease-out;
}
@keyframes urudhohg6 {
from {
width: 2rem;
}
to {
width: 5rem;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment