Want more features on Pastebin? Sign Up, it's FREE!
Guest

Lazy

By: iamdangavin on Aug 24th, 2012  |  syntax: jQuery  |  size: 0.49 KB  |  views: 92  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /* Loads and fades in image */
  2.  
  3. function loadImage(image, callback) {
  4.         if (typeof callback == 'undefined') { callback = function(){}; }
  5.  
  6.         if (image.attr("src") == "images/core/transparent.gif") {
  7.        
  8.                 image.animate({opacity:0}, 50, function() {
  9.                         image.bind('load', function(){
  10.                             image.animate({opacity:1}, 1000).css({height:'auto'});
  11.                             callback();
  12.             });
  13.                         image.attr("src", image.attr("data-original"));
  14.                 });
  15.  
  16.         }
  17. }
clone this paste RAW Paste Data