Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 Animation in IE8/9

I understand that CSS3 animations do not work in IE. I was just wondering if there is a JavaScript workaround for this problem.

Here's a link to what I want to recreate in IE: http://animation.kashoo.co.uk/

Any advice would be great.

like image 326
Michael Bulpitt Avatar asked Jun 01 '12 17:06

Michael Bulpitt


People also ask

Can CSS3 be used to create Animations for Internet Explorer 9 users?

Animation, transition and transformations are not supported in IE9 or lower.

Can we create animation using CSS3?

CSS allows animation of HTML elements without using JavaScript or Flash! In this chapter you will learn about the following properties: @keyframes. animation-name.

What is required for CSS3 animation?

You must specify at least two properties animation-name and the animation-duration (greater than 0), to make the animation occur. However, all the other animation properties are optional, as their default values don't prevent an animation from happening. Note: Not all CSS properties are animatable.


2 Answers

After a quick Google search I found a jQuery plugin that changes jQuery's standard $.animate() function so that it will use CSS3 transitions whenever possible:

$.animate-enhanced

edit:

After trying the above plugin on a site of mine, the site broke. I'm not sure if you will have the same problem or not, but here is my workaround:

You will need Modernizr.js

Basically, you check (with Modernizr) whether the browser supports a given feature, and then decide whether to animate with CSS3 or Javascript.

For example:

(Let's say you are animation an object to move to the right by 200px)

if(Modernizr.csstransitions) {
    // use your appropriate browser prefixes
    yourDomObject.style.transition = 'left 2s';
    yourDomObject.style.left = parseInt(yourDomObject.style.left) + 200 + 'px'

} else {

    var left = parseInt($(yourDomObject).css('left')) + 200 + 'px';
    $(yourDomObject).animate({
        'left' : left
    },2000,'easeOutExpo');
}
like image 154
Martin Avatar answered Oct 05 '22 17:10

Martin


Check out jQuery's animate functions: http://api.jquery.com/animate/

like image 32
Josh Siok Avatar answered Oct 05 '22 17:10

Josh Siok