masonry icon indicating copy to clipboard operation
masonry copied to clipboard

Function of columnWidth doesnt work on Package v3 file

Open rafaelfaria opened this issue 12 years ago • 4 comments

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.

rafaelfaria avatar Mar 14 '14 09:03 rafaelfaria

why not use columnWidth: '.post_col'

http://masonry.desandro.com/options.html#columnwidth

SilverKenn avatar Mar 17 '14 17:03 SilverKenn

@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'
});

desandro avatar Mar 17 '14 17:03 desandro

I tried. Didn't work. All the boxes stack into each other.

rafaelfaria avatar Apr 01 '14 01:04 rafaelfaria

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.

desandro avatar Apr 01 '14 02:04 desandro