Skip to main content
100%

8. Interacting with React(Mouse Follower)

✓ Published1🌍 Public
PPrashish Paudel
Last edited Mar 30, 2021
Created on Mar 30, 2021

A single dark circle tracks the mouse cursor across an SVG canvas. The visualization uses React’s `useState` and `useCallback` to manage the cursor’s coordinates, with an `onMouseMove` event handler updating the circle’s `cx` and `cy` attributes in real time. The circle’s radius is fixed at 30 pixels, and the SVG viewport is 960 by 500 pixels. The code initializes the mouse position to the canvas center before any interaction.

AI-generated description

A program that follows your mouse with a circle.

MIT Licensed

Similar vizzes