Because keyframe animations in CSS are 2 parts — the animation name on the style, and the @keyframes declaration in the root — to create a mixin the way you're describing, it would have to be set up something like this:
@mixin bgAnimation($name, $start-position, $end-position) {
animation-name: $name;
@at-root {
@keyframes #{$name} {
0% {
background-position: $start-position;
}
100% {
background-position: $end-position;
}
}
}
}
You could then use the mixin with the following:
.class {
animation: 10s linear;
animation-iteration-count: infinite;
@include bgAnimation(animation-name, 0px, 100px);
}
That would compile into the following CSS:
.class {
animation: 10s linear;
animation-iteration-count: infinite;
animation-name: animation-name;
}
@keyframes animation-name {
0% {
background-position: 0px;
}
100% {
background-position: 100px;
}
}