The CSS3
, is not yet ready for professional level animations in large scalable projects. For simple things, - CSS3 is the winner, we can’t even argue about it. If you’re looking for animations mais robustas
we will examine the following points:
1. The flow control
Imagine you spent nights writing incredible, cutting-edge animation codes on pure CSS3. And now - here comes the hard part. You want to control them - pause, stop, turn, run asynchronously, one after the other, put in a timeline and time line. Well, good luck with that. Literally, it’s almost impossible. With javascript solutions (like GSAP) it’s easy as making a pie! Write a few lines of javascript code and you’re ready to go!
2. Animating several properties
Imagine that you want to scale a div and in the middle of this animation, they start to rotate it and change the color of the border. You cannot animate individual properties distinctly. However, JS-based solutions allow you to literally animate any numerical property in a variety of forms (just write Animate to 50% of the initial width, Animate to 0px, Animate to -50px and then to 150px) .
3. Organisation
Code for larger projects can easily change and you may have to write complex animations, this is when code organization is the key! With CSS3 it is almost impossible to group your animations into logical chunks to manage easily, just calling methods and callbacks.
4. Compatibility
CSS3 transitions do not work in older browsers. What’s more - each browser handles them differently (and adds its own mistakes to your application). With few animations on your page it’s probably easier to check if everything goes well, but it can become impossible once you go to a larger project. Javascript solutions provide an abstraction layer. You don’t have to worry about specific browser behaviors This is where libraries are doing their job!
Completion
CSS animations are "bad"? Certainly not! In fact, they are great for simple transitions between states (such as rollovers), when compatibility with older browsers is not required. CSS does transformations very well, and CSS animations can be very appealing to developers who prefer to put all their animation and logical presentation in the CSS layer. However, Javascript-based animation offers much more flexibility, better workflow for interactively rich and complex animations, and often runs as fast (or even faster) than CSS-based animation.
Summary:
css3:
- Positive point: fast
- Negative point: Animation is primitive
js:
- Plus: Animation (math) can have sophisticated methods,
much more interactive for the user
- Downside: Some browsers might block js, it might be
heavy, has charging time
In that website has a nice comparison, with animations, performance test and more! Take a look.
Source
What do you mean "animations with CSS limit depending on the browser"? Could explain this excerpt better?
– Renan Gomes
those times I asked the same here http://answall.com/questions/59798/%C3%89-correct-use-js-to-do-the-effects-of-an-html
– Andrey Hartung
Related / possible duplicate: http://answall.com/questions/51542/css-ou-jquery-para-anima%C3%A7%C3%A3o
– bfavaretto
@Renan, try to run some animation on IE8 or IE7.
– Wesley Redfield
@Andreyhartung It’s not the same question because my question was not about using javascript to manipulate css, however, pitting one against the other for creating animations. Anyway, your question also helped my studies! Thank you!
– Wesley Redfield
@bfavaretto Very related, however, as it was posted below, the use of Jquery decreases in terms of performance, different from CSS which is faster. And in this case, I was looking for a purer javascript animation - and suggested GSAP! Thanks for sharing another link as well!
– Wesley Redfield
@Wesleyredfield but, if you think about it, there are also modern features in Javascript to handle animations that don’t work in those browsers you mentioned. But finally...
– Renan Gomes
@Renan Please, if you have fonts that strengthen this you are saying, please share it with us! Thanks!
– Wesley Redfield
@Wesleyredfield
window.requestAnimationFrame
is an example.– Renan Gomes