apolinario / spriteOnHover

5 stars 6 forks source link

JS Fix for animations in Internet Explorer #1

Open ocorral opened 12 years ago

ocorral commented 12 years ago

IE doesn’t know what background-position is, it only knows 2 other calls: background-position-x and background-position-y. Here is a function to handle this problem.

(function($) {
  jQuery.fn.backgroundPosition = function() {
    var p = $(this).css('background-position');
    if(typeof(p) === 'undefined') return $(this).css('background-position-x') + ' ' + $(this).css('background-position-y');
    else return p;
  };
})(jQuery);

Also be sure to replace line 82 and 125 from:

var backgroundPos = $(this_parent).css('background-position').split(" ");

To:

var backgroundPos = $(this_parent).backgroundPosition().split(" ");
apolinario commented 12 years ago

Thank you very much, I'm gonna fix this asap and soon launch the new version with this issue fixed!