(payload: ChartGPUEventPayload)
| 79 | }; |
| 80 | |
| 81 | const onMouseMove = (payload: ChartGPUEventPayload): void => { |
| 82 | lastPointer = payload; |
| 83 | if (!enabled) return; |
| 84 | |
| 85 | // Pan only for mouse drags, only when inside grid. |
| 86 | const e = payload.originalEvent; |
| 87 | const shouldPan = payload.isInGrid && (isShiftLeftDrag(e) || isMiddleButtonDrag(e)); |
| 88 | |
| 89 | if (!shouldPan) { |
| 90 | clearPan(); |
| 91 | return; |
| 92 | } |
| 93 | |
| 94 | const plotWidthCss = payload.plotWidthCss; |
| 95 | if (!(plotWidthCss > 0) || !Number.isFinite(plotWidthCss)) { |
| 96 | clearPan(); |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | if (!isPanning) { |
| 101 | isPanning = true; |
| 102 | lastPanGridX = payload.gridX; |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | const dxCss = payload.gridX - lastPanGridX; |
| 107 | lastPanGridX = payload.gridX; |
| 108 | if (!Number.isFinite(dxCss) || dxCss === 0) return; |
| 109 | |
| 110 | const { start, end } = zoomState.getRange(); |
| 111 | const span = end - start; |
| 112 | if (!Number.isFinite(span) || span === 0) return; |
| 113 | |
| 114 | // Convert grid-local px to percent points *within the current window*. |
| 115 | // “Grab to pan” behavior: dragging right should move the window left (show earlier data). |
| 116 | const deltaPct = -(dxCss / plotWidthCss) * span; |
| 117 | if (!Number.isFinite(deltaPct) || deltaPct === 0) return; |
| 118 | zoomState.pan(deltaPct); |
| 119 | }; |
| 120 | |
| 121 | const onMouseLeave = (_payload: ChartGPUEventPayload): void => { |
| 122 | lastPointer = null; |
nothing calls this directly
no test coverage detected