Skip to main content
100%

Interaction with React: Mouse follower

✓ Published1🌍 Public
EElvira Nassirova
Last edited Jun 8, 2021
Created on Jun 8, 2021

A circle follows the mouse cursor within an SVG canvas. The example uses React's `useState` and `useCallback` to track the cursor's `clientX` and `clientY` coordinates, updating the circle's `cx` and `cy` attributes on every `onMouseMove` event. The SVG and circle are rendered directly through ReactDOM, with no D3 visualization logic, though the D3 library is loaded in the page. The interaction is purely event-driven, with the initial circle position centered at width/2, height/2.

AI-generated description

A program that follows your mouth with a circle.

MIT Licensed

Similar vizzes