From 599a3d0d7a39d811afa395f8963213b27dec3870 Mon Sep 17 00:00:00 2001 From: devformatters2 <177856586+devformatters2@users.noreply.github.com> Date: Mon, 2 Sep 2024 19:58:22 +0800 Subject: [PATCH] feat(tabs): listen mouse* events on $nav instead of window --- src/components/SquareTabs/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/SquareTabs/index.tsx b/src/components/SquareTabs/index.tsx index 084f3b8a35..886768f992 100644 --- a/src/components/SquareTabs/index.tsx +++ b/src/components/SquareTabs/index.tsx @@ -86,13 +86,13 @@ export const SquareTabs: React.FC> & { calculateGradient() $nav.addEventListener('scroll', calculateGradient) - window.addEventListener('mousemove', handleMouseMove) - window.addEventListener('mouseup', handleMouseUp) + $nav.addEventListener('mousemove', handleMouseMove) + $nav.addEventListener('mouseup', handleMouseUp) return () => { $nav.removeEventListener('scroll', calculateGradient) - window.removeEventListener('mousemove', handleMouseMove) - window.removeEventListener('mouseup', handleMouseUp) + $nav.removeEventListener('mousemove', handleMouseMove) + $nav.removeEventListener('mouseup', handleMouseUp) } }, [$nav, $container, isDragging])