1

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'});
  • 1
    Do you mean you want to ensure they load in the same order? Consider using objects instead of strings, and add additional data to them, such as an ID or index. You could also set `maxConnections` to 1, so they load one at a time. – Lanny Mar 29 '22 at 12:26
  • 1
    @Lanny Thank you so much . Your answer helps me a lot! – Lunkai Yang Mar 30 '22 at 02:37

0 Answers0