MapComplete/UI/Image/SlideShow.ts

29 lines
820 B
TypeScript
Raw Normal View History

2020-10-14 12:15:09 +02:00
import {UIEventSource} from "../../Logic/UIEventSource";
2021-06-11 22:51:45 +02:00
import BaseUIElement from "../BaseUIElement";
2021-06-14 19:21:33 +02:00
import $ from "jquery"
2020-06-24 00:35:19 +02:00
2021-06-11 22:51:45 +02:00
export class SlideShow extends BaseUIElement {
2020-06-24 00:35:19 +02:00
2021-06-14 19:21:33 +02:00
private readonly embeddedElements: UIEventSource<BaseUIElement[]>;
constructor(embeddedElements: UIEventSource<BaseUIElement[]>) {
2021-06-11 22:51:45 +02:00
super()
2021-06-14 19:21:33 +02:00
this.embeddedElements = embeddedElements;
}
protected InnerConstructElement(): HTMLElement {
2021-06-11 22:51:45 +02:00
const el = document.createElement("div")
2021-06-14 19:21:33 +02:00
el.classList.add("slic-carousel")
this.embeddedElements.addCallbackAndRun(elements => {
2021-06-11 22:51:45 +02:00
for (const element of elements ?? []) {
element.SetClass("slick-carousel-content")
2021-06-14 19:21:33 +02:00
el.appendChild(element.ConstructElement())
2021-06-11 22:51:45 +02:00
}
});
2021-06-11 22:51:45 +02:00
2021-06-14 19:21:33 +02:00
return el;
}
}