Repository navigation
Add zoom controls to the research maps - #336
Merged
Merged
Conversation
Zoom in, out and reset buttons, drag to pan once zoomed, and ctrl/pinch wheel to zoom at the cursor, by moving the SVG's viewBox. Pins and lines scale back by 1/zoom so they keep their size. The controls are hidden until the script runs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
|
Preview: https://15d01c51.nstarkman-space.pages.dev Built from |
… in calc() keeps the pins r:calc(3 * var(--k)) is a unitless number; a browser that does not take that for r makes the whole declaration invalid at computed-value time, which resets r to 0 and hides every pin. calc(3px * var(--k)) is a length everywhere. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changing code or schema
What and why: The two world maps on /research/ (collaborators, conferences) were fixed at world scale, where the dozens of pins around Boston, New York and Europe sit on top of each other. This adds zoom.
src/lib/mapzoom.jsmoves the SVG'sviewBox, keeping the aspect ratio, so the figure's height never changes and nothing below it jumps. Up to 8×.--k(= 1/zoom) inmap.css, so they stay the same size on screen instead of growing into blobs.hiddenin the markup and shown by the script, so with JavaScript off the page is unchanged. A drag that moved is not treated as a click on the pin it ended over.tests/mapzoom.test.jscovers the view maths (clamping to the map, zoom about the cursor, zoom limits). Driven in a browser: zoom, pan, wheel, reset, pin sizes and clicking a pin all behave.Not included: two-finger pinch on touch screens (the page's own pinch-zoom still works) and keyboard panning; the buttons are keyboard-reachable.
npm testpasseslink.relortypeadded; no schema changeScreenshots
The collaborator map on /research/ — with JavaScript off the map is unchanged; with it on, here zoomed to the eastern US and Europe.
JavaScript off
JavaScript on, zoomed
🤖 Generated with Claude Code