jQuery - Compatibility Problem with Internet Explorer 7 and Opera

Posted by Marius on Stack Overflow See other posts from Stack Overflow or by Marius
Published on 2010-04-14T12:39:31Z Indexed on 2010/04/14 12:43 UTC
Read the original article Hit count: 206

Hello there,

I have this counter which counts + 1 every time somebody shares content from the site. When it happens, the social icon that was clicked will bounce.

It works in Firefox,Chrome, IE8, and Opera, however the bouncing animation is wrong in opera.

 $.fn.countExternal = function(animSpeed, num) {
  // for each counter
  this.each(function(){
   // select all the digit containers
   var span = $(this).children();
   // count the num of digit containers
   var len = $(span).length;
   // get the current count
   u = $(span).text();
   // copy variable and add increment(s)
   v = num + '';
   // foreach digit container...
   for (i=v.length - 1; i >= 0; i--) {
    // ...check which digits are not affected by the increment(s)
    if (v.charAt(i) == u.charAt(i)) {
     break;
    }
   }

   // slice from the total number of digit containers the digits containers which needs updating.
   slce = len - (v.length - (i + 1))
   var updates = $(span).slice(slce);
   // loop through each digit container and fade out ...
   $(updates).fadeTo(animSpeed, 0,function(){
    $(updates).each(function(index){
     f = i + 1 + index;
     // ...then pick the right digit and update the digit...
     $(this).text(v.charAt(f));
     // ...before fading back in. Cycle complete.
     $(this).fadeTo(animSpeed, 1);
    });
   });
  });
 };
}) (jQuery);

Demo (NSFW) is here (look underneath the social sharing icons).

Any idea how I can solve the IE, and possibly the Opera compatibility problem?

Thank you for your time.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about counter