Merge pull request #1 from dotcli/bugfix/masonry-layout-refresh.

BUGFIX: make masonry recalculate layout after image's loaded
This commit is contained in:
Hamish MacDonald 2018-07-18 22:58:43 +12:00 committed by GitHub
commit a2f46b1281
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,21 +31,21 @@ function ViewMasonry()
fitWidth: true,
transitionDuration: 0,
});
console.log(3 + ' ' + this.msnry);
console.log(3);
// var imgLoad = imagesLoaded('.grid');
// function onAlways( instance ) {
// console.log('all images are loaded');
// parent.msnry.reloadItems();
// parent.msnry.layout();
// }
// imgLoad.on( 'always', onAlways );
// // imgLoad.off( 'always', onAlways );
// imgLoad.on( 'progress', function(instance, image)
// {
// var result = image.isLoaded ? 'loaded' : 'broken';
// console.log( 'image is ' + result + ' for ' + image.img.src );
// });
var imgLoad = imagesLoaded('.grid');
function onAlways( instance ) {
console.log('all images are loaded');
this.msnry.layout();
console.log(this.msnry);
}
imgLoad.on( 'always', onAlways.bind(this) );
// imgLoad.off( 'always', onAlways );
imgLoad.on( 'progress', function(instance, image)
{
var result = image.isLoaded ? 'loaded' : 'broken';
console.log( 'image is ' + result + ' for ' + image.img.src );
});
}
}