Skip to main content
100%

Mouse Follower (Make Something)

✓ Published0🌍 Public
MMatthew Dzwil
Last edited Jan 16, 2023
Created on Jan 16, 2023
Forked from Mouse Follower

A rectangle moves in opposition to the mouse's cursor, its position derived from the inverted coordinates of the pointer within the viewport. Clicking resets the rectangle to the mouse's location by swapping the axes. Built with D3 v7 and the `select` API, the visualization uses `svg.on('mousemove')` and `svg.on('click')` handlers to update state, which then drives the rectangle's `x` and `y` attributes, styled with an orange fill and purple stroke.

AI-generated description

A rectangle that does the opposite of the mouse's movements using unidirectional data flow. When you click, it brings the rectangle back to the mouse.

What I used for help/inspiration:

To change to rectangle: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/rect

To change color of rectangle: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/style

MIT Licensed

Similar vizzes