Closed patrulea closed 10 months ago
I know this is due to me being a JavaScript novice but I’d be appreciative of any advice.
I achieved this with no use of the library.
productImages.forEach((image) => {
if (image.complete) {
randomPosition(image.parentElement);
} else {
image.addEventListener("load", () => {
randomPosition(image.parentElement);
});
}
});
imagesLoaded
waits until allproduct
’s images are loaded to runproductRandomPosition
on everyproduct
at once.Though, I’d like to run
productRandomPosition
on everyproduct
as soon as its images load, independent of the rest of the images’ progress.This is my current code: