mapcomplete/UI/Image/SlideShow.ts

41 lines
1 KiB
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";
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-11 22:51:45 +02:00
private readonly _element: HTMLElement;
2020-06-24 00:35:19 +02:00
constructor(
2021-06-11 22:51:45 +02:00
embeddedElements: UIEventSource<BaseUIElement[]>) {
super()
const el = document.createElement("div")
this._element = el;
el.classList.add("slick-carousel")
require("slick-carousel")
2021-02-15 17:44:19 +01:00
// @ts-ignore
2021-06-11 22:51:45 +02:00
el.slick({
autoplay: true,
arrows: true,
dots: true,
lazyLoad: 'progressive',
variableWidth: true,
centerMode: true,
centerPadding: "60px",
2021-06-11 22:51:45 +02:00
adaptive: true
});
embeddedElements.addCallbackAndRun(elements => {
for (const element of elements ?? []) {
element.SetClass("slick-carousel-content")
}
});
2021-06-11 22:51:45 +02:00
}
protected InnerConstructElement(): HTMLElement {
return this._element;
}
}