I want to convert a simple CSS3 animation to pure JavaScript (not in jQuery, because I think it's overkill to load the entire library for such a simple thing).
It's about the animation bounceInUp from http://daneden.me/animate/. Sample demo: http://jsfiddle.net/ELDf7/
@keyframes bounceInUp {
0% {
opacity: 0;
transform: translateY(2000px);
}
60% {
opacity: 1;
transform: translateY(-30px);
}
80% {
transform: translateY(10px);
}
100% {
transform: translateY(0);
}
}
At http://javascript.info/tutorial/animation, there's a tutorial about how to do animations with JavaScript. But I'm not very good at mathematics, so I made a graph in PhotoShop to show how the animation should run in JavaScript (approximately):

(The graph plotter for other 'deltas' can be found here)
Is it possible to make a mathematical formula from this graph in pure JavaScript that returns the "delta" of the animation?
I've tried some things with the bounce function, but it didn't really work. (http://jsfiddle.net/ELDf7/2/)
Edit: I managed to make a good mathematical formula:

-Math.cos(2*Math.PI*progress) + Math.pow(progress, 1) * ((1.5 + 1) * progress - 1.5);
But now I've got another problem, the animation starts with half of the image showing, and not with the entire image hidden, like it appears like the CSS3 animation.
For a live demo of the JavaScript animation, see here: http://jsfiddle.net/ELDf7/14/
Does anyone know how I can change it so that the image is entirely hidden initially? Maybe it's possible to make a variable that contains the height of the image and then JavaScript makes a calculation so that the animation doesn't start until half of the image appears.
transitionshorthand property. Animations use theanimationshorthand property and@keyframes.progress += 1;insidebounceworks. see