Animation How to - Use jQuery Image Animation Fallback For CSS3 Transitions








Question

We would like to know how to use jQuery Image Animation Fallback For CSS3 Transitions.

Answer


<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--  w  ww .jav a  2 s .  com-->
$("img").each(function() {
    $.data(this, 'size', { width: $(this).width(), height: $(this).height() });
}).hover(function() {
    $(this).stop().animate({ height: $.data(this,'size').height*1.6, 
                             width: $.data(this,'size').width*1.6 }, 2000);
}, function() {
    $(this).stop().animate({ height: $.data(this,'size').height, 
                             width: $.data(this,'size').width }, 2000);
});
});
</script>
</head>
<body>
  <img src="http://www.java2s.com/style/download.png"
    width="300" height="200" />
</body>
</html>

The code above is rendered as follows: