( container: HTMLElement, zoomState: ZoomState, options?: DataZoomSliderOptions )
| 28 | type DragMode = 'left-handle' | 'right-handle' | 'pan-window'; |
| 29 | |
| 30 | export function createDataZoomSlider( |
| 31 | container: HTMLElement, |
| 32 | zoomState: ZoomState, |
| 33 | options?: DataZoomSliderOptions |
| 34 | ): DataZoomSlider { |
| 35 | const height = options?.height ?? 32; |
| 36 | const marginTop = options?.marginTop ?? 8; |
| 37 | const zIndex = options?.zIndex ?? 4; |
| 38 | const showPreview = options?.showPreview ?? false; |
| 39 | |
| 40 | const root = document.createElement('div'); |
| 41 | root.style.display = 'block'; |
| 42 | root.style.width = '100%'; |
| 43 | root.style.height = `${height}px`; |
| 44 | root.style.marginTop = `${marginTop}px`; |
| 45 | root.style.boxSizing = 'border-box'; |
| 46 | root.style.position = 'relative'; |
| 47 | root.style.zIndex = `${zIndex}`; |
| 48 | root.style.userSelect = 'none'; |
| 49 | root.style.touchAction = 'none'; |
| 50 | |
| 51 | // track: full-width bar that hosts preview + window selection. |
| 52 | const track = document.createElement('div'); |
| 53 | track.style.position = 'relative'; |
| 54 | track.style.height = '100%'; |
| 55 | track.style.width = '100%'; |
| 56 | track.style.boxSizing = 'border-box'; |
| 57 | track.style.borderRadius = '8px'; |
| 58 | track.style.borderStyle = 'solid'; |
| 59 | track.style.borderWidth = '1px'; |
| 60 | track.style.overflow = 'hidden'; |
| 61 | root.appendChild(track); |
| 62 | |
| 63 | // preview: miniature context under the selection (optional; can be a solid bar for now). |
| 64 | const preview = document.createElement('div'); |
| 65 | preview.style.position = 'absolute'; |
| 66 | preview.style.inset = '0'; |
| 67 | preview.style.pointerEvents = 'none'; |
| 68 | preview.style.opacity = '0.4'; |
| 69 | preview.style.display = showPreview ? 'block' : 'none'; |
| 70 | track.appendChild(preview); |
| 71 | |
| 72 | // window: the selected range. |
| 73 | const windowEl = document.createElement('div'); |
| 74 | windowEl.style.position = 'absolute'; |
| 75 | windowEl.style.top = '0'; |
| 76 | windowEl.style.bottom = '0'; |
| 77 | windowEl.style.left = '0%'; |
| 78 | windowEl.style.width = '100%'; |
| 79 | windowEl.style.boxSizing = 'border-box'; |
| 80 | windowEl.style.cursor = 'grab'; |
| 81 | track.appendChild(windowEl); |
| 82 | |
| 83 | // left/right handles. |
| 84 | const leftHandle = document.createElement('div'); |
| 85 | leftHandle.style.position = 'absolute'; |
| 86 | leftHandle.style.left = '0'; |
| 87 | leftHandle.style.top = '0'; |
no test coverage detected