Reputation: 27
I am using preloadjs, but I have a question that when I store the images in the queue object. How do I distinguish which image put in the right place.
here is storing the images code
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/mountains-clouds.jpg');
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/adventure-alpine-alps-714258.jpg');
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/170407220921-07-iconic-mountains-pitons-restricted.jpg');
queue.loadFile('https://s3.amazonaws.com/coursetro/stuff/170407220916-04-iconic-mountains-matterhorn-restricted.jpg');
here is setting the image Dom to html
const handleFileComplete=(event)=>{
const type=event.type;
if (type=="fileload"){
galleryRef.current.appendChild(event.result); //this is just a simple traversal How to distinguish
};
}
queue.on("fileload",handleFileComplete);
Thank you for helping me :)
=============================FIXED===============================
Thank for Lanny's answer. We can just set the id when we load the image
queue.loadFile({id:"dance1",src:'https://s3.amazonaws.com/coursetro/stuff/170407220916-04-iconic-mountains-matterhorn-restricted.jpg'});
Upvotes: 1
Views: 36