Skip to main content
100%

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title

✓ Published0🌍 Public
HHerst
Last edited Nov 4, 2017
Created on Sep 23, 2017

This example demonstrates an interactive rectangle that can be resized and repositioned within a fixed map area using mouse or touch gestures. Dragging the corner handles adjusts the rectangle’s width and height while enforcing minimum size constraints, and dragging the rectangle’s interior moves it without exceeding the map boundaries. The visualization uses the D3.js library’s zoom and drag behaviors, with SVG elements for rendering and a custom zoom constraint function to keep the rectangle within the coordinate space. Numeric inputs for x, y, width, and height update live as the rectangle changes, reflecting the current state of the data.

AI-generated description

The rectangle can be resized by click-dragging the circle handles in the corners around but minimal size lengths are maintained (therefore the corner handles also cannot switch sides).

The rectangle can be dragged around by click-dragging anywhere else on the rectangle.

gpl-3.0 Licensed

Similar vizzes