Skip to main content
100%

Mouse Follower Simple

✓ Published2🌍 Public
CCurran Kelleher
Last edited May 12, 2024
Created on May 12, 2024
Forked from Mouse Follower

This example demonstrates a simple interactive visualization where a circle follows the mouse cursor within an SVG container. The circle’s position is stored in the application state, and every mouse movement updates the state using immutable update patterns, spreading the previous state object and assigning new x and y coordinates. The code uses D3’s `select` and `pointer` APIs to handle the `mousemove` event, and a data join to render the SVG and circle elements. The circle is initialized at the center of the container before any mouse interaction occurs.

AI-generated description

A program that follows the mouse around and changes its color using immutable update patterns.

Challenge

  • Use this pattern to make something else respond to mouse events
MIT Licensed

Similar vizzes