Moving Rectangle
✓ Published0🌍 Public
LLaurafharding
Last edited May 30, 2016
Created on Feb 26, 2018
Four range sliders control the x and y position and the width and height of a single black-outlined SVG rectangle. The input events call a custom `update` function that modifies the rectangle’s corresponding attributes, while also dynamically adjusting each slider’s maximum value to prevent the shape from extending beyond the SVG canvas. The example uses D3.js selections and event listeners to bind the HTML slider inputs directly to the SVG element’s properties.
AI-generated descriptionThis is an example of how to change the attributes of a SVG element through a HTML input. It is not fully bug tested - near the edges of the graph, the rectangle can get "stuck".
See http://www.puzzlr.org/ for more d3 related fun!