mr-crocs-adventures/js/MediaImageCollection.js

28 lines
682 B
JavaScript
Raw Permalink Normal View History

2020-01-22 22:50:45 +01:00
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);
}
}