From 037202dc838c089ad553388c13d0df2be46fff89 Mon Sep 17 00:00:00 2001 From: JX_PPP <62788828+Jippp@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:54:02 +0800 Subject: [PATCH] fix(ColorPicker): fix slider mouse move behavior bug (#3042) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: ä¿color-picker-panel slider鼠标move缺陷 * fix: color-picker-panel slider mouseup mousemove绑定缺陷 --------- Co-authored-by: jhl --- src/hooks/useDrag.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/hooks/useDrag.ts b/src/hooks/useDrag.ts index c18a7b72d5..50de7f99ad 100644 --- a/src/hooks/useDrag.ts +++ b/src/hooks/useDrag.ts @@ -44,17 +44,15 @@ const useDrag = (ref, options: DraggableProps) => { const handlePointerUp = (e: MouseEvent) => { isDraggingRef.current = false; end(getCoordinate(e), e); - const element = ref.current; - element.removeEventListener('mouseup', handlePointerUp); - element.removeEventListener('mousemove', handlePointerMove); + document.removeEventListener('mouseup', handlePointerUp); + document.removeEventListener('mousemove', handlePointerMove); }; const handlePointerDown = (e: MouseEvent) => { isDraggingRef.current = true; start(getCoordinate(e), e); - const element = ref.current; - element.addEventListener('mouseup', handlePointerUp); - element.addEventListener('mousemove', handlePointerMove); + document.addEventListener('mouseup', handlePointerUp); + document.addEventListener('mousemove', handlePointerMove); }; useEffect(() => {