I want to know when an image has finished loading. Is there a way to do it with a callback?
If not, is there a way to do it at all?
I want to know when an image has finished loading. Is there a way to do it with a callback?
If not, is there a way to do it at all?
Image.onload() will often work.
To use it, you'll need to be sure to bind the event handler before you set the src attribute.
Related Links:
Example Usage:
You could use the load()-event in jQuery but it won't always fire if the image is loaded from the browser cache. This plugin https://github.com/peol/jquery.imgloaded/raw/master/ahpi.imgload.js can be used to remedy that problem.
If you are using React.js, you could do this:
// ...
// ... }
Where:
Life is too short for jquery.
.complete
+ callbackThis is a standards compliant method without extra dependencies, and waits no longer than necessary:
Source: http://www.html5rocks.com/en/tutorials/es6/promises/
these functions will solve the problem, you need to implement the
DrawThumbnails
function and have a global variable to store the images. I love to get this to work with a class object that has theThumbnailImageArray
as a member variable, but am struggling!called as in
addThumbnailImages(10);