Repository navigation
feat(gui): framework-neutral viewport with native pan/zoom (#218, fixes #147) - #226
Merged
Merged
Conversation
Replaces react-zoom-pan-pinch with a native CSS-transform pan/zoom and fixes the zoom-clamp bug. Part of epic #214, strangler-on-main: React still ships; Svelte stays behind the dev-only entry and out of the bundle (unchanged at 595.75 kB). - lib/panzoom.ts: pure pan/zoom math (zoomAt/pan/centered/clampScale). Fixes #147 — scale clamped to [0.1, 8] but translate is NEVER bounded, so a plot larger than the viewport pans freely to its overflow and a smaller one zooms up to 8x. - state/preview-session.svelte.ts: runes port of usePreviewGeneration (validate → schema-validate → plotDefinition → PNG) with a monotonic request-id stale guard. - components/canvas/Viewport.svelte: empty/generating/error/placeholder/image states, layer scrubber, zoom+refresh+export toolbar, native wheel + pointer-drag pan/zoom. Wired into the Prepare workspace. react-zoom-pan-pinch stays in package.json for the live React path until #221. 715 tests (pan/zoom math incl. the #147 small-zoom-up & large-pan-free cases, preview-session incl. a stale-response race, viewport states + wheel/toolbar). Adversarially reviewed (#147 algebra verified; stale-guard race test added). Closes #218. Closes #147. Refs #214
7 tasks
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.
Closes #218. Closes #147. Replaces the
react-zoom-pan-pinchPNG-preview viewport with a framework-neutral native pan/zoom, and fixes the long-standing zoom-clamp bug. Part of epic #214 (strangler-on-main: React still ships; Svelte stays behind the dev-only entry and out ofvite build— unchanged at 595.75 kB).What changed
src/lib/panzoom.ts— a small pure pan/zoom controller (zoomAt/pan/centered/clampScale). Applied astransform: translate(x,y) scale(s)withtransform-origin: 0 0.[0.1, 8]; translate is never clamped to the image/container bounds. So a plot larger than the viewport pans freely to its overflow, and one smaller zooms up to 8×. Unit-tested both directions.src/state/preview-session.svelte.ts— runes module portingusePreviewGeneration: validate inputs → schema-validate →plotDefinition(API) → PNG, with loading/error/warnings and a monotonic request-id stale guard (a superseded response never overwrites a newer one).src/components/canvas/Viewport.svelte— the viewport: empty / generating / error / placeholder / image states, the layer scrubber, the zoom+refresh+export toolbar, and native wheel + pointer-drag pan/zoom. Wired into the Prepare workspace center region.react-zoom-pan-pinchStill in
package.jsonbecause the live ReactVisualizationCanvasstill uses it; zero.sveltefiles import it. Removed at the #221 cutover.Verification
tsc,svelte-check(0/0), 714 vitest tests (+22: pan/zoom math incl. the GUI bug: plot viewer zoom is clamped to image bounds #147 small-zoom-up & large-pan-free cases, preview-session incl. stale guard, viewport states + wheel/toolbar wiring), coverage 82.8/72.2/81.0/81.9 (> 60/65/50/60), stylelint,lint:css:vars,vite build, bundle budget.Notes for reviewers
tauri dev; the browser preview shows the non-image states.Closes #218. Closes #147. Part of #214.