From a065ec67a9eb6be33a5bfd9eef587531a2814284 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Fri, 2 Jun 2023 17:35:25 +0200 Subject: [PATCH] fix: eye dropper not accounting for offsets (#6640) --- src/components/EyeDropper.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/EyeDropper.tsx b/src/components/EyeDropper.tsx index e24b8d40..794ad602 100644 --- a/src/components/EyeDropper.tsx +++ b/src/components/EyeDropper.tsx @@ -77,8 +77,8 @@ export const EyeDropper: React.FC<{ colorPreviewDiv.style.left = `${clientX + 20}px`; const pixel = ctx.getImageData( - clientX * window.devicePixelRatio, - clientY * window.devicePixelRatio, + clientX * window.devicePixelRatio - appState.offsetLeft, + clientY * window.devicePixelRatio - appState.offsetTop, 1, 1, ).data; @@ -182,6 +182,8 @@ export const EyeDropper: React.FC<{ swapPreviewOnAlt, previewType, excalidrawContainer, + appState.offsetLeft, + appState.offsetTop, ]); const ref = useRef(null);