2020-10-14 12:15:09 +02:00
|
|
|
import {UIEventSource} from "../../Logic/UIEventSource";
|
|
|
|
import {UIElement} from "../UIElement";
|
2020-11-02 18:59:21 +01:00
|
|
|
import Combine from "../Base/Combine";
|
2021-01-29 03:23:53 +01:00
|
|
|
// @ts-ignore
|
|
|
|
import $ from "jquery"
|
2020-06-24 00:35:19 +02:00
|
|
|
|
|
|
|
export class SlideShow extends UIElement {
|
|
|
|
|
|
|
|
private readonly _embeddedElements: UIEventSource<UIElement[]>
|
|
|
|
|
|
|
|
constructor(
|
2020-09-13 00:53:24 +02:00
|
|
|
embeddedElements: UIEventSource<UIElement[]>) {
|
2020-06-24 00:35:19 +02:00
|
|
|
super(embeddedElements);
|
|
|
|
this._embeddedElements = embeddedElements;
|
2021-01-29 03:23:53 +01:00
|
|
|
this._embeddedElements.addCallbackAndRun(elements => {
|
|
|
|
for (const element of elements ?? []) {
|
|
|
|
element.SetClass("slick-carousel-content")
|
|
|
|
}
|
|
|
|
})
|
2020-07-06 13:47:22 +02:00
|
|
|
|
2020-06-24 00:35:19 +02:00
|
|
|
}
|
|
|
|
|
2020-07-26 02:01:34 +02:00
|
|
|
InnerRender(): string {
|
2021-01-29 03:23:53 +01:00
|
|
|
return new Combine(
|
|
|
|
this._embeddedElements.data,
|
|
|
|
).SetClass("block slick-carousel")
|
2020-11-06 04:02:53 +01:00
|
|
|
.Render();
|
2020-06-24 00:35:19 +02:00
|
|
|
}
|
|
|
|
|
2020-09-13 03:29:44 +02:00
|
|
|
Update() {
|
|
|
|
super.Update();
|
|
|
|
for (const uiElement of this._embeddedElements.data) {
|
|
|
|
uiElement.Update();
|
|
|
|
}
|
|
|
|
}
|
2020-06-28 00:06:23 +02:00
|
|
|
|
2021-01-29 03:23:53 +01:00
|
|
|
protected InnerUpdate(htmlElement: HTMLElement) {
|
|
|
|
require("slick-carousel")
|
|
|
|
if(this._embeddedElements.data.length == 0){
|
|
|
|
return;
|
|
|
|
}
|
2021-02-15 17:44:19 +01:00
|
|
|
// @ts-ignore
|
2021-01-29 03:23:53 +01:00
|
|
|
$('.slick-carousel').not('.slick-initialized').slick({
|
2021-02-06 00:05:38 +01:00
|
|
|
autoplay: true,
|
2021-01-29 03:23:53 +01:00
|
|
|
arrows: true,
|
|
|
|
dots: true,
|
|
|
|
lazyLoad: 'progressive',
|
|
|
|
variableWidth: true,
|
|
|
|
centerMode: true,
|
|
|
|
centerPadding: "60px",
|
|
|
|
adaptive: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-13 03:29:44 +02:00
|
|
|
}
|