| 
									
										
										
										
											2023-03-29 17:21:20 +02:00
										 |  |  | import { Store } from "../../Logic/UIEventSource" | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  | import BaseUIElement from "../BaseUIElement" | 
					
						
							| 
									
										
										
										
											2021-06-17 13:17:16 +02:00
										 |  |  | import { Utils } from "../../Utils" | 
					
						
							|  |  |  | import Combine from "../Base/Combine" | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  | export class SlideShow extends BaseUIElement { | 
					
						
							| 
									
										
										
										
											2022-06-05 02:24:14 +02:00
										 |  |  |     private readonly embeddedElements: Store<BaseUIElement[]> | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-05 02:24:14 +02:00
										 |  |  |     constructor(embeddedElements: Store<BaseUIElement[]>) { | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  |         super() | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |         this.embeddedElements = embeddedElements | 
					
						
							| 
									
										
										
										
											2022-03-13 02:46:42 +01:00
										 |  |  |         this.SetStyle("scroll-snap-type: x mandatory; overflow-x: auto") | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     protected InnerConstructElement(): HTMLElement { | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  |         const el = document.createElement("div") | 
					
						
							| 
									
										
										
										
											2021-06-15 16:18:58 +02:00
										 |  |  |         el.style.minWidth = "min-content" | 
					
						
							|  |  |  |         el.style.display = "flex" | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |         el.style.justifyContent = "center" | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  |         this.embeddedElements.addCallbackAndRun((elements) => { | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |             if (elements.length > 1) { | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |                 el.style.justifyContent = "unset" | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-15 16:18:58 +02:00
										 |  |  |             while (el.firstChild) { | 
					
						
							|  |  |  |                 el.removeChild(el.lastChild) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |             elements = Utils.NoNull(elements).map((el) => | 
					
						
							|  |  |  |                 new Combine([el]) | 
					
						
							| 
									
										
										
										
											2021-06-17 13:17:16 +02:00
										 |  |  |                     .SetClass("block relative ml-1 bg-gray-200 m-1 rounded slideshow-item") | 
					
						
							| 
									
										
										
										
											2021-06-18 01:25:13 +02:00
										 |  |  |                     .SetStyle( | 
					
						
							|  |  |  |                         "min-width: 150px; width: max-content; height: var(--image-carousel-height);max-height: var(--image-carousel-height);scroll-snap-align: start;" | 
					
						
							|  |  |  |                     ) | 
					
						
							| 
									
										
										
										
											2021-06-17 13:17:16 +02:00
										 |  |  |             ) | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  |             for (const element of elements ?? []) { | 
					
						
							| 
									
										
										
										
											2021-06-14 19:21:33 +02:00
										 |  |  |                 el.appendChild(element.ConstructElement()) | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-01-29 03:23:53 +01:00
										 |  |  |         }) | 
					
						
							| 
									
										
										
										
											2021-06-11 22:51:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-15 16:18:58 +02:00
										 |  |  |         const wrapper = document.createElement("div") | 
					
						
							|  |  |  |         wrapper.style.maxWidth = "100%" | 
					
						
							|  |  |  |         wrapper.style.overflowX = "auto" | 
					
						
							|  |  |  |         wrapper.appendChild(el) | 
					
						
							|  |  |  |         return wrapper | 
					
						
							| 
									
										
										
										
											2021-01-29 03:23:53 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-13 03:29:44 +02:00
										 |  |  | } |