mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Basic implementations
This commit is contained in:
28
js/MediaImageCollection.js
Normal file
28
js/MediaImageCollection.js
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user