Skip to content

Instantly share code, notes, and snippets.

@jackie
Created October 29, 2012 18:20
Show Gist options
  • Save jackie/3975454 to your computer and use it in GitHub Desktop.
Save jackie/3975454 to your computer and use it in GitHub Desktop.
new lazyload modifications
Network.View.Project.Lazyload = $.Core.View.Entity.extend({
}, // proto
{
init : function( lazyload ) {
var $images = $("#project-modules img.lazy-load"),
images_loaded = 0;
$images.lazyload({
placeholder : Config.NETIMAGESURL + "site/grey.png",
effect : "fadeIn",
effectspeed : 150,
threshold : 1500,
enabled : lazyload
});
$images.on('appear', function() {
$images.trigger('countAndShow');
});
$images.on('countAndShow', function() {
if( this.loaded && !this.counted ) {
this.counted = true;
images_loaded++;
}
if( images_loaded > 4 ) {
$images.off('countAndShow');
$images.trigger('appear');
}
});
} // init
}); // Lazyload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment