Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Masonry.prototype.measureColumns causes javascript error when container is empty #358

Closed
michaelcbrook opened this issue Jun 19, 2013 · 0 comments

Comments

@michaelcbrook
Copy link

I have an empty div on which I've initialized Masonry, but the following line causes a javascript error when the div contains 0 elements matching itemSelector:

var firstItemElem = this.items[0].element;

in the function Masonry.prototype.measureColumns

If the columnWidth value is present, there is no need to check the width of the first element. If columnWidth is not present and there are no elements in the container, it would be okay to either throw an error, automatically set some arbitrary width, or wait until an item is added to determine the width.

Fixing this bug would allow me to have an empty Masonry container in which I can insert elements at a later time. For now, I must create a dummy element and then remove it by javascript after Masonry is initialized.

For anyone getting the error: "Uncaught TypeError: Cannot read property 'element' of undefined" this may be related to your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant