From 9381c2183d98befa81ee5187800909c1377ebcff Mon Sep 17 00:00:00 2001 From: hamed-musallam <35760236+hamed-musallam@users.noreply.github.com> Date: Tue, 2 Apr 2024 09:26:12 +0200 Subject: [PATCH] fix: crosshair label position (#3001) --- src/component/1d/tool/XLabelPointer.tsx | 24 +++++++---------------- src/component/2d/tools/XYLabelPointer.tsx | 11 ++--------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/component/1d/tool/XLabelPointer.tsx b/src/component/1d/tool/XLabelPointer.tsx index 548a97083..c9027f5bc 100644 --- a/src/component/1d/tool/XLabelPointer.tsx +++ b/src/component/1d/tool/XLabelPointer.tsx @@ -1,5 +1,5 @@ import { Spectrum1D } from 'nmr-load-save'; -import { useCallback, CSSProperties } from 'react'; +import { CSSProperties } from 'react'; import { useBrushTracker } from '../../EventsTrackers/BrushTracker'; import { useMouseTracker } from '../../EventsTrackers/MouseTracker'; @@ -10,10 +10,8 @@ import useSpectrum from '../../hooks/useSpectrum'; const style: CSSProperties = { cursor: 'crosshair', - transformOrigin: 'bottom right', position: 'absolute', - top: '-18px', - left: '-30px', + paddingRight: '5px', pointerEvents: 'none', overflow: 'visible', userSelect: 'none', @@ -31,16 +29,6 @@ function XLabelPointer() { (activeSpectrum as Spectrum1D)?.info.nucleus, ); - const getXValue = useCallback( - (xVal) => { - if (activeSpectrum) { - const xInvert = scaleX().invert(xVal); - return format(xInvert); - } - }, - [activeSpectrum, format, scaleX], - ); - if ( !activeSpectrum || brushState.step === 'brushing' || @@ -52,15 +40,17 @@ function XLabelPointer() { ) { return null; } + + const x = scaleX().invert(position.x); + return (