| 105 | } |
| 106 | |
| 107 | function onPointerDown(event: PointerEvent): void { |
| 108 | event.preventDefault(); |
| 109 | dragging.value = true; |
| 110 | startX = event.clientX; |
| 111 | // The stored width can exceed the current cap (e.g. after the window narrows |
| 112 | // or a side panel opens). Clamp the drag start so the handle responds |
| 113 | // immediately instead of first covering an invisible delta. |
| 114 | startWidth = clamp(width.value); |
| 115 | activeEl = event.currentTarget as HTMLElement; |
| 116 | activePointerId = event.pointerId; |
| 117 | // Suppress text selection / show a resize cursor for the whole drag. |
| 118 | if (typeof document !== 'undefined') { |
| 119 | document.body.style.userSelect = 'none'; |
| 120 | document.body.style.cursor = 'col-resize'; |
| 121 | } |
| 122 | try { |
| 123 | activeEl.setPointerCapture(activePointerId); |
| 124 | } catch { |
| 125 | // setPointerCapture may be unavailable in some test environments |
| 126 | } |
| 127 | activeEl.addEventListener('pointermove', onPointerMove); |
| 128 | activeEl.addEventListener('pointerup', endDrag); |
| 129 | activeEl.addEventListener('pointercancel', endDrag); |
| 130 | } |
| 131 | |
| 132 | onBeforeUnmount(endDrag); |
| 133 | |