desandro/imagesloaded — Issue #20: imagesloaded() sometimes called too soon + lack of check if image is loaded
Author: lmeurs
Created: 2012-02-10 20:12:28+00:00
State: open

Hi there,

Great script, but ran into 2 problems when changing the source of an image to load another. I might have a solution that I successfully tested on Chrome15, FF10, IE9 and IE8 (XP).

At http://www.wishdesign.nl/fora/imagesloaded/problem.htm you see the demo. In FF10 & IE8/9: when you click the image and imageloaded() is called, the image URL is changed, but the width remained the width of the previous image. Keep clicking, it keeps occurring.

A workaround seems to be to clone the image element and replace the original image with this clone. See http://www.wishdesign.nl/fora/imagesloaded/fix1.htm.

Now the right widths are shown, but not always for uncached images. So I built in a function that checks whether the image is actually loaded. Now everything seems fine, see http://www.wishdesign.nl/fora/imagesloaded/fix2.htm.

These demo's are based on a single image and my solution is not implemented in imageloaded() yet, so see it as a proof of concept?

Cheers,

Laurens Meurs