masonry('reload') on ver v3.1.4
Hello Des,
Thank for the great plugin
So, I have this code which is working correctly on masonry v2.1.07
$content.append($data).imagesLoaded(function(){
$content.masonry({
itemSelector: '.items',
columnWidth: 290,
isAnimated: true,
animationOptions: {
duration: 750,
easing: 'linear',
queue: false
}
}).masonry('reload');
});
how do I implement reload or make it work for ver 3?
by the way, $data is ajax request value
Thanks Kenn
See docs on upgrading from Masonry v2
reloadmethod from v2 is nowreloadItems. But for your example, you shouldn't even need it, since Masonry was just initialized. Nothing will be reloaded- animationOptions are no longer used
- isAnimated is no longer used
I would re-write that code as:
$content.append($data).imagesLoaded(function(){
$content.masonry({
itemSelector: '.items',
columnWidth: 290,
transitionDuration: '7.5s'
});
});
Hi Desandro,
Thanks for you response
masonry won't seem to render properly when the appended content is from ajax request.
I've check many template and plugins that uses masonry with ajax and they seem still used the v2 and uses reload method. the most important thing I want that forces me to use v3 is the columnWidth: '.items', options which is not available on v2
I have search everywhere and I couldn't really find a solution.
luckily, upon having maybe hundreds of testing, I have managed to accomplish it using this method, not sure if this is even the correct way. but its working properly for me now so i can used it until I find a really best method
$content.masonry();
$content.append($data).masonry('appended', $data, true);
$.each($data, function (e) {
$(this).delay(e * $delay).fadeIn(400, function () {
$(this).imagesLoaded(function(){
$content.masonry({
itemSelector: '.items',
columnWidth: '.items',
gutter: 13,
transitionDuration: 0,
isAnimated: true,
}).masonry('reloadItems');
})
}) // .masonry('reloadItems'); //or maybe in here?
})
forgive my ignorance as I am just starting to learn jquery for a few months
thanks anyway for this greet plugin.
Cheers