I would like to use webkit animation with @-webkit-keyframes but being able to dynamically modify the values on the rule, so that the animation is not static. All the samples I found use a static @-webkit-frames, is there a way to customize with Javascript?
+1
A:
I had to create a new style rule in the loaded style sheets. Seems to work great in chrome 5.0.342.9 beta (at least)
var lastSheet = document.styleSheets[document.styleSheets.length - 1];
lastSheet.insertRule("@-webkit-keyframes " + newName + " { from { top: 0px; } to {top: " + newHeight + "px;} }", lastSheet.cssRules.length);
and then assign the animation name using element.style
element.style.webkitAnimationName = newName;
CNelson
2010-04-12 20:12:52
Awesome! that worked great! thank you!
Drew LeSueur
2010-07-05 18:37:31
A:
I wish I could credit for this, but here's a link to someone who managed to modify an existing animation, as opposed to creating a new animation.
http://gitorious.org/webkit/webkit/commit/438fd0b118bd9c2c82b6ab23956447be9c24f136
I've ran this to verify that it does, indeed, work.
RussellUresti
2010-04-12 21:17:15