adamwulf / Columnizer-jQuery-Plugin

The Columnizer jQuery Plugin will automatically layout your content in newspaper column format. You can specify either column width or a static number of columns. And, of course, it’s easy to use!
http://welcome.totheinter.net/columnizer-jquery-plugin/
Other
758 stars 147 forks source link

Columnizer works only after window resizing or inspect element. #220

Closed sanjay-github closed 7 years ago

sanjay-github commented 7 years ago

Hi, I am trying columnizer on my menu so as to remove extra spaces. Initially i.e on page load , it columnizes but last column is tallest. Once I inspect the html, it works perfectly fine.

This is my code , let me know where I am wrong.

var requireQueue = function (modules, callback) {
            function load(queue, results) {
                if (queue.length) {
                    require([queue.shift()], function (result) {
                        results.push(result);
                        load(queue, results);
                    });
                } else {
                    callback.apply(null, results);
                }
            }
            load(modules, []);
        };
        requireQueue([
            'jquery',
            'RB_Megamenu/js/rb_megamenu',
            'RB_Megamenu/js/jquery.columnizer'
        ], function ($) {
            $(".rb-megamenu").rbMegamenu();
            $(".action.nav-toggle").click(function () {
                $(".navigation.rb-megamenu.side-megamenu").slideToggle();
            });

            $('.mega-columns').columnize({width:90, columns: 4, lastNeverTallest: true});
        });
adamwulf commented 7 years ago

does the menu also contain images? you may need to use ignoreImageLoading=false in the options if those images affect the layout of the menu

sanjay-github commented 7 years ago

No, it does not contain any images.

adamwulf commented 7 years ago

usually when something like this happens, it's because columnizer is running before it's able to calculate the true sizes of the elements its working with. i'm not sure how rbMegamenu() works ,but if that does anything async then that might cause issues. you can try columnizing after a short timeout. if your css has the hidden menu as display:none, then you can also try having the css be visibility:hidden; instead of display:none, which helps with calculations of hidden elements.

sanjay-github commented 7 years ago

You are right adamwulf. Once I changed the property from display:none to visibility:hidden, it started working fine. Thanks ! :+1: