Skip to content

Instantly share code, notes, and snippets.

@alykat
Created January 8, 2014 16:19
Show Gist options
  • Save alykat/8319458 to your computer and use it in GitHub Desktop.
Save alykat/8319458 to your computer and use it in GitHub Desktop.
function setup_css_animations() {
var prefixes = [ '-webkit-', '-moz-', '-o-', '' ];
var keyframes = '';
var filmstrip_steps = 25;
...
for (var i = 0; i < prefixes.length; i++) {
...
var filmstrip = '';
for (var f = 0; f < filmstrip_steps; f++) {
var current_pct = f * (100/filmstrip_steps);
filmstrip += current_pct + '% {background-position:0 -' + (f * 100) + '%;' + prefixes[i] + 'animation-timing-function:steps(1);}';
}
keyframes += '@' + prefixes[i] + 'keyframes filmstrip {' + filmstrip + '}';
}
var s = document.createElement('style');
s.innerHTML = keyframes;
$('head').append(s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment