bigbite / macy.js

http://macyjs.com/
MIT License
1.3k stars 156 forks source link

TypeError: n.replace is not a function #39

Closed nathkrill closed 6 years ago

nathkrill commented 6 years ago

I am using Macy (the latest version from npm - 2.3.0) and upon initialisation I get the error: Uncaught TypeError: n.replace is not a function.

Here is how I am using Macy:

var masonry = (function () {
    'use strict';

    var feed,
        macy;

    function reinit() {
        macy.recalculate();
    }

    function init() {
        feed = document.querySelector('.feed');

        if (!feed) {
            return;
        }

        macy = Macy({
            container: feed,
            columns: 1,
            waitForImages: true,
            mobileFirst: true,
            breakAt: {
                768: 3
            }
        });

        window.resize = reinit;
    }

    document.addEventListener('DOMContentLoaded', init);

    return {
        init: init,
        reinit: reinit
    }

}());

The idea is that I can call masonry.reinit any time I need to reinitialise and it will recalculate.

nathkrill commented 6 years ago

Saw my problem - I was passing a variable into container rather than an element selector. Perhaps this would make a nice feature?

jrmd commented 6 years ago

hey @nathkrill

I will look to implement this when i have some free time as i believe it would be handy :)

Closing for now as its not a bug :)