jQueryFeed has the best jquery plugins database, tutorials, css effects with jquery examples, jquery for beginners, jquery for designers, jquery for developers... If you like this project, please support us just clicking you know where :)

jQuery.mb.CSSAnimate - Use CSS3 transition to animate DOM Elements via jQuery

by http://pupunzi.open-lab.com/2011/12/11/jquery-mb-cssanimate-use-css3-transition-to-animate-dom-elements-via-jquery/ 10 months ago (585 views)

jQuery.mb.CSSAnimate - Use CSS3 transition to animate DOM Elements via jQuery

As most of you know there are new features in CSS3 that let you animate HTML elements using just CSS.

Using CSS3 “transition” you can control which property to apply, the duration of the transition, the transition timing and the transition delay.
The transition considers also the “transform” parameter specified in the CSS class.

Actually jQuery .animate() method doesn’t consider the CSS3 support and it applies the animation using javascript.

That’s why I realized the mb.CSSAnimate() simple method that uses CSS3 instead of javascript to animate HTML elements; it provides a callback function fired once the transition ends as jquery.animate() does and it fallback to jquery.anomate() if “transition” is not supported by the browser.

Why should we consider to use CSS3 instead of javascript to animate HTML elements?
Well… First CSS3 animation use less CPU than javascript; the UX is smoothness (especially on mobile devices); on iOs is hardware accelerated; you can animate also background color, rotation, scale, skew or any of the CSS properties available that the default .animate() method doesn’t provide.

What happens if the browser doesn’t support CSS3 using mb.CSSAnimate()?
Actually the mb.CSSAnimate() method has a fallback to the jquery.animate() one; of course if you were animating a “transform: rotate()” property you’ll lose it :-) .

How can I use specific prefixed CSS property with mb.CSSAnimate()?
To use specific browsers property with mb.CSSAnimate you just need to remove the prefix from the property.

SEE ARTICLE


Related items...