(e: WheelEvent)
| 124 | }; |
| 125 | |
| 126 | const onWheel = (e: WheelEvent): void => { |
| 127 | if (!enabled || disposed) return; |
| 128 | |
| 129 | const p = lastPointer; |
| 130 | if (!p || !p.isInGrid) return; |
| 131 | |
| 132 | const plotWidthCss = p.plotWidthCss; |
| 133 | const plotHeightCss = p.plotHeightCss; |
| 134 | if (!(plotWidthCss > 0) || !(plotHeightCss > 0)) return; |
| 135 | |
| 136 | const deltaYCss = normalizeWheelDelta(e, plotHeightCss); |
| 137 | const deltaXCss = normalizeWheelDeltaX(e, plotWidthCss); |
| 138 | |
| 139 | // Check if horizontal scroll is dominant (pan operation). |
| 140 | if (Math.abs(deltaXCss) > Math.abs(deltaYCss) && deltaXCss !== 0) { |
| 141 | const { start, end } = zoomState.getRange(); |
| 142 | const span = end - start; |
| 143 | if (!Number.isFinite(span) || span === 0) return; |
| 144 | |
| 145 | // Convert horizontal scroll delta to percent pan. |
| 146 | // Positive deltaX = scroll right = pan right (show earlier data). |
| 147 | const deltaPct = (deltaXCss / plotWidthCss) * span; |
| 148 | if (!Number.isFinite(deltaPct) || deltaPct === 0) return; |
| 149 | |
| 150 | e.preventDefault(); |
| 151 | zoomState.pan(deltaPct); |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | // Otherwise, proceed with vertical scroll zoom logic. |
| 156 | if (deltaYCss === 0) return; |
| 157 | |
| 158 | const factor = wheelDeltaToZoomFactor(deltaYCss); |
| 159 | if (!(factor > 1)) return; |
| 160 | |
| 161 | const { start, end } = zoomState.getRange(); |
| 162 | const span = end - start; |
| 163 | if (!Number.isFinite(span) || span === 0) return; |
| 164 | const r = clamp(p.gridX / plotWidthCss, 0, 1); |
| 165 | const centerPct = clamp(start + r * span, 0, 100); |
| 166 | |
| 167 | // Only prevent default when we are actually consuming the wheel to zoom. |
| 168 | e.preventDefault(); |
| 169 | |
| 170 | if (deltaYCss < 0) zoomState.zoomIn(centerPct, factor); |
| 171 | else zoomState.zoomOut(centerPct, factor); |
| 172 | }; |
| 173 | |
| 174 | const enable: InsideZoom['enable'] = () => { |
| 175 | if (disposed || enabled) return; |
nothing calls this directly
no test coverage detected