d3.js: mouse drag a la iphone: decceleration
This example demonstrates an interactive image viewer that supports panning, zooming, centering, and resetting using mouse drags, scrollwheel, and keyboard shortcuts. It implements a swipe gesture with deceleration, where releasing the mouse during a drag continues the image’s momentum. The interface also displays a cycling tip-of-the-day overlay after five seconds of inactivity, which fades in and out using D3 transitions. The code relies on `d3.behavior.drag`, `d3.timer`, and `d3.json` to load the configuration, while rendering a large external JPEG image inside a clipped container.
AI-generated descriptionUser Interface
A huge image is shown on screen; you can pan/zoom the image to see all the detail or the entire image at once.
Each of the possible operations can be performed by one of several mouse actions. Some operations have only one type of mouse activity.
When the operation can be performed using the keyboard, then the key bindings are listed as well.
Swipe
Click and drag the image (background), release during drag, i.e. act it out as a swipe movement.
keys: ---
Pan
Either swipe (see above) or drag the image (background) and hold in place, then release, to pan the image around.
You may also move the mouse near the 'edges' to auto-pan.
keys: [Page Up], [Page Down], [Arrow Up], [Arrow Down]
Centering
Click somewhere to center on that pixel.
keys: ---
Zoom
Zooming in/out:
- Scrollwheel
- CTRL+drag (right/up is zoom in, left/down is zoom out)
keys: [+], [-], [Keypad +], [Keypad -]
Reset
Right click.
keys: [END], [E]
TODO
Create and test mobile/tablet actions for each of the operations.