Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Mouse Follower

Public visualization

Viewing a saved revision (read-only)

cd15432455ed4f6f8971ee0bb21c6687

Mouse Follower

0 stars0🌍 Public
IIsh Takkar
Last edited Jun 19, 2021
Created on Jun 19, 2021

This example shows a single circle that follows the mouse cursor across the full browser window. The circle’s position updates in real time as the user moves the pointer over an SVG canvas. Built with React (version 16.9.0) and ReactDOM, the component uses the `useState` hook to store the mouse coordinates and the `useCallback` hook to handle `mousemove` events, retrieving `clientX` and `clientY` from the event object. The SVG is sized to `window.innerWidth` and `window.innerHeight`, with the circle’s `cx` and `cy` attributes bound to the current mouse position.

AI-generated description

A program that follows your mouse with a circle.