Skip to content

Instantly share code, notes, and snippets.

@scarfacedeb
Created February 27, 2014 09:37
Show Gist options
  • Save scarfacedeb/9247101 to your computer and use it in GitHub Desktop.
Save scarfacedeb/9247101 to your computer and use it in GitHub Desktop.
initMasonry = function(){
console.log( "init masonry" );
// We don't need masonry on one-column layouts!
if ( checkMasonryBreakpoint() ) {
requestAnimationFrame(function(){
masonry = new Masonry( artworks, self.settings.masonry );
masonry.on( 'postLayout', function(){
console.log('layout done, just this one time');
requestAnimationFrame(function(){
InfinitelyLazy.update();
});
// return true to trigger an event listener just once
return true;
});
// give browser time to calculate padding-bottom percentages of lazy images into px.
// otherwise, it would break masonry layout (height: 36px for every column).
requestAnimationFrame(function(){
masonry.layout();
});
});
return true;
} else {
// use this value in conditions to detect if masonry was inited
return false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment