Skip to content

Commit

Permalink
feat: delay mouse position reset
Browse files Browse the repository at this point in the history
  • Loading branch information
hmerritt committed May 31, 2024
1 parent 7e5ec31 commit cb99b86
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/view/components/experimental/DotGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,16 @@ export const DotGrid: React.FC<DotGridProps> = ({
y = touch.clientY;
}
} else if (e.type === "mouseout" || e.type === "touchend") {
x = -1000;
y = -1000;
setTimeout(() => {
// If mouse position has changed, abort reset (this means mouse has moved back into tracking area)
if (x !== mousePosition.current.x || y !== mousePosition.current.y)
return;

x = -1000;
y = -1000;
mousePosition.current.x = x;
mousePosition.current.y = y;
}, 1000);
}

mousePosition.current.x = x;
Expand Down

0 comments on commit cb99b86

Please sign in to comment.