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

Possible bug with makeArray helper function in 5.0.0 #312

Open
lordmatt opened this issue Oct 31, 2023 · 2 comments
Open

Possible bug with makeArray helper function in 5.0.0 #312

lordmatt opened this issue Oct 31, 2023 · 2 comments

Comments

@lordmatt
Copy link

I'm seeing the following error in the console

imagesloaded.pkgd.js:138 Uncaught TypeError: obj is not iterable
    at makeArray (imagesloaded.pkgd.js:138:34)
    at new ImagesLoaded (imagesloaded.pkgd.js:168:19)
    at $.fn.imagesLoaded (imagesloaded.pkgd.js:430:20)
    at HTMLDocument.<anonymous> ((index):713:23)
    at j (jquery.min.js:2:27295)
    at Object.fireWith [as resolveWith] (jquery.min.js:2:28108)
    at Function.ready (jquery.min.js:2:29942)
    at HTMLDocument.J (jquery.min.js:2:30308)
makeArray	@	imagesloaded.pkgd.js:138
ImagesLoaded	@	imagesloaded.pkgd.js:168
$.fn.imagesLoaded	@	imagesloaded.pkgd.js:430
(anonymous)	@	(index):713
j	@	jquery.min.js:2
fireWith	@	jquery.min.js:2
ready	@	jquery.min.js:2
J	@	jquery.min.js:2
@devjennz
Copy link

devjennz commented Feb 6, 2024

When you use jQuery and you get console error "obj is not iterable" or "h is not iterable" (minified version 5.0.0)

Solution:

let masonry = $( '.gallery' ).masonry();
let imgLoad = imagesLoaded( masonry[0] );

@peterbrowse
Copy link

peterbrowse commented Mar 21, 2024

If anyone has multiple masonry/isotope grids on the same page, you'll have to use something like the below to apply imageLoaded to each individual instance:

var grids = document.querySelectorAll('.grid'); grids.forEach(function(grid) { var imgLoad = imagesLoaded(grid); // Progress event listener imgLoad.on('progress', function(instance, image) { // This function is triggered each time an image is loaded var result = image.isLoaded ? 'loaded' : 'failed'; console.log('An image ' + result + ' for grid', grid); // Optionally, you can update progress indicators here }); // Completion event listener imgLoad.on('always', function() { // Code to execute after all images in this grid have loaded console.log('All images loaded for grid', grid); }); });

👍

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

3 participants