Skip to main content
100%

Movement of circle via mouse

✓ Published1🌍 Public
RRedSorrel
Last edited Sep 15, 2021
Created on Sep 15, 2021

A single circle tracks the user's mouse in real time across a full-browser SVG canvas, updating its center position on every pointer movement. Built with React, the app uses the `useState` hook to store mouse coordinates and a `useCallback` event handler for `onMouseMove`. The circle's `cx` and `cy` attributes are bound to the current state, and React re-renders the SVG element accordingly. The initial circle is positioned at the viewport center, and the circle radius is fixed at 30 pixels.

AI-generated description

Moving circle with mouse; interaction

MIT Licensed

Similar vizzes