(
e: PointerEvent
)
| 835 | const resize = (): void => resizeInternal(true); |
| 836 | |
| 837 | const getNearestPointFromPointerEvent = ( |
| 838 | e: PointerEvent |
| 839 | ): { readonly match: HitTestMatch | null; readonly isInGrid: boolean } => { |
| 840 | const rect = canvas.getBoundingClientRect(); |
| 841 | if (!(rect.width > 0) || !(rect.height > 0)) return { match: null, isInGrid: false }; |
| 842 | |
| 843 | const x = e.clientX - rect.left; |
| 844 | const y = e.clientY - rect.top; |
| 845 | |
| 846 | const plotLeftCss = resolvedOptions.grid.left; |
| 847 | const plotTopCss = resolvedOptions.grid.top; |
| 848 | const plotWidthCss = rect.width - resolvedOptions.grid.left - resolvedOptions.grid.right; |
| 849 | const plotHeightCss = rect.height - resolvedOptions.grid.top - resolvedOptions.grid.bottom; |
| 850 | if (!(plotWidthCss > 0) || !(plotHeightCss > 0)) return { match: null, isInGrid: false }; |
| 851 | |
| 852 | const gridX = x - plotLeftCss; |
| 853 | const gridY = y - plotTopCss; |
| 854 | |
| 855 | const isInGrid = |
| 856 | gridX >= 0 && |
| 857 | gridX <= plotWidthCss && |
| 858 | gridY >= 0 && |
| 859 | gridY <= plotHeightCss; |
| 860 | |
| 861 | if (!isInGrid) return { match: null, isInGrid: false }; |
| 862 | |
| 863 | const xMin = resolvedOptions.xAxis.min ?? cachedGlobalBounds.xMin; |
| 864 | const xMax = resolvedOptions.xAxis.max ?? cachedGlobalBounds.xMax; |
| 865 | const yMin = resolvedOptions.yAxis.min ?? cachedGlobalBounds.yMin; |
| 866 | const yMax = resolvedOptions.yAxis.max ?? cachedGlobalBounds.yMax; |
| 867 | |
| 868 | // Make hit-testing zoom-aware (mirror coordinator percent->domain mapping). |
| 869 | const baseXDomain = normalizeDomain(xMin, xMax); |
| 870 | const zoomRange = coordinator?.getZoomRange() ?? null; |
| 871 | const xDomain = (() => { |
| 872 | if (!zoomRange) return baseXDomain; |
| 873 | const span = baseXDomain.max - baseXDomain.min; |
| 874 | if (!Number.isFinite(span) || span === 0) return baseXDomain; |
| 875 | const start = zoomRange.start; |
| 876 | const end = zoomRange.end; |
| 877 | const zMin = baseXDomain.min + (start / 100) * span; |
| 878 | const zMax = baseXDomain.min + (end / 100) * span; |
| 879 | return normalizeDomain(zMin, zMax); |
| 880 | })(); |
| 881 | const yDomain = normalizeDomain(yMin, yMax); |
| 882 | |
| 883 | // Cache hit-testing scales for identical (rect, grid, axis domain) inputs. |
| 884 | const canReuseScales = |
| 885 | interactionScalesCache !== null && |
| 886 | interactionScalesCache.rectWidthCss === rect.width && |
| 887 | interactionScalesCache.rectHeightCss === rect.height && |
| 888 | interactionScalesCache.plotWidthCss === plotWidthCss && |
| 889 | interactionScalesCache.plotHeightCss === plotHeightCss && |
| 890 | interactionScalesCache.xDomainMin === xDomain.min && |
| 891 | interactionScalesCache.xDomainMax === xDomain.max && |
| 892 | interactionScalesCache.yDomainMin === yDomain.min && |
| 893 | interactionScalesCache.yDomainMax === yDomain.max; |
| 894 |
no test coverage detected