Created
February 27, 2014 09:37
-
-
Save scarfacedeb/9247101 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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