PolyFill/Shim for CSS transitions and animations
Solution 1
There is a very good CSS3 transition polyfill for jQuery called jQuery.transition.
You can just use the usual animate() method in jQuery, and it will automatically use CSS3 transitions if available, and if not, it will fall back to vanilla jQuery.
Solution 2
Google's Polymer Project includes a Web Animations polyfill for the draft W3C Web Animations spec.
Caveat emptor: This is pretty early work, as the W3C spec is only a Public Working Draft, so anything could change. Also, the Polymer polyfills look like they're targeting only the latest version of browsers (e.g. IE10+) so it may not suit your needs. Still, this is early on in the project, so keep an eye on it and experiment.
If you're careful to test the platforms your users are on, you could take advantage of the future web today.
Related videos on Youtube
Graham Conzett
Updated on June 27, 2020Comments
-
Graham Conzett almost 4 years
Google is failing me somewhat on this (I think because the terminology for PolyFill/Shim/Spackle is new and diverse at the moment). I'm trying to find a good JavaScript PolyFill or Shim for webkit's (and now as of the RC FireFox 4's) CSS transitions.
I have found this work that Weston Ruter did, but it hasn't been updated in a while, and uses browser detection as opposed to feature detection.
I also uncovered FakeSmile but it is geared mostly to SVG animation.
Does anyone know of any good libraries to fill in this functionality? Preferably something that would work with Modernizr and is still being actively worked on. So far the best option looks like starting with what Weston came up with.
-
Domenic about 13 yearsThis is kind of backward from what the OP is looking for, but +1 anyway, since in many cases you do want this functionality in JavaScript instead of CSS. (There are definitely cases where CSS is more appropriate though, e.g. transitioning between normal and
:hover
states.) -
Sindre Sorhus about 13 yearsI know, but the best polyfill is actually this way. The other way is by loading and parsing the stylesheet, and extracting the transition parameters and converting them to JavaScript. Something that is quite resource hungry.
-
Oskar Austegard over 12 yearsThank you for pointing me to this polyfill - I had been struggling with other buggy plugins that gave me nothing but grief. This one works beautifully.
-
NeuronQ over 10 years@SindreSorhus parsing a CSS file doesn't seem that resource hungry compared to what people are routinely now using Js for :) Do you know of any solution based on this "resource hungry" mechanism? It's exactly what I'm looking for and I'll probably end up coding something like this myself if I don't find any...
-
Adrien Be almost 10 yearsjsbin please! (old browsers like IE8 are not supported by jsfiddle)
-
Jeremy Harris about 8 yearsDirect link to GitHub project: github.com/web-animations/web-animations-js