PolyFill/Shim for CSS transitions and animations

14,869

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.

Share:
14,869

Related videos on Youtube

Graham Conzett
Author by

Graham Conzett

Updated on June 27, 2020

Comments

  • Graham Conzett
    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
    Domenic about 13 years
    This 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
    Sindre Sorhus about 13 years
    I 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
    Oskar Austegard over 12 years
    Thank 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
    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
    Adrien Be almost 10 years
    jsbin please! (old browsers like IE8 are not supported by jsfiddle)
  • Jeremy Harris
    Jeremy Harris about 8 years
    Direct link to GitHub project: github.com/web-animations/web-animations-js

Related