Function of columnWidth doesnt work on Package v3 file
I'm trying to port the script I had it working on v2.1.08 to Masonry PACKAGED v3.1.4.
I'm trying the same sintaxe which i assumed it should work, but it doesnt seem to be executing the function i set to columnWidth.
I'm using requireJS and bridget this time.
I debugged the old one with a simple alert, and i can see it fine, when i do the same thing to the v3. nothing happens.
here is my code. Nothing fancy.
define([
'jquery'
, 'underscore'
, 'jquery.masonry'
, 'jquery.bridget'
, 'jquery.imagesloaded'
], function ($, _, Masonry, bridget) {
// DOC - http://masonry.desandro.com/appendix.html#requirejs
bridget('masonry', Masonry);
var $container = $('#post_grids'),
gutWidth = 30;
$container.imagesLoaded( function(){
$container.masonry({
itemSelector : '.post_col',
gutterWidth: gutWidth,
columnWidth: function(containerWidth) {
var box_width = $container.children('.post_col').width();
//alert(box_width);
return box_width;
}
});
});
});
After executing this, i can see that the masonry has been applied but all of the boxes seems to pile up on top of each other on position 0 0.
why not use columnWidth: '.post_col'
http://masonry.desandro.com/options.html#columnwidth
@SilverKenn has it right. If you're just using the width of .post_col, then you should use element sizing
$container.masonry({
itemSelector : '.post_col',
gutterWidth: gutWidth,
columnWidth: '.post_col'
});
I tried. Didn't work. All the boxes stack into each other.
Could you provide a reduced test case? See Submitting Issues in the contributing guidelines.
I'm happy to take a look, but without a test case, there's no way to debug your example. Closing for now.