mr-crocs-adventures/js/MediaImageCollection.js
2020-01-22 22:50:45 +01:00

28 lines
682 B
JavaScript

import InterfaceEvent from "./events/InterfaceEvent.js";
import ImageLoadedEvent from "./events/ImageLoadedEvent";
export default class MediaImageCollection
{
constructor()
{
this.mediaImages = [];
this.numberImagesLoaded = 0;
window.addEventListener(
ImageLoadedEvent.NAME,
() => {
this.numberImagesLoaded++;
if (this.numberImagesLoaded === this.mediaImages.length) {
window.dispatchEvent(new InterfaceEvent.MEDIA_COLLECTION_LOADED);
}
}
)
}
addMediaImage(mediaImage)
{
this.mediaImages.push(mediaImage);
}
}