feat: add pan, zoom, and auto-fit to whiteboard canvas#31
Open
YizukiAme wants to merge 4 commits intoTHU-MAIC:mainfrom
Open
feat: add pan, zoom, and auto-fit to whiteboard canvas#31YizukiAme wants to merge 4 commits intoTHU-MAIC:mainfrom
YizukiAme wants to merge 4 commits intoTHU-MAIC:mainfrom
Conversation
When AI generates whiteboard elements that exceed the fixed 1000x562.5 canvas, content was clipped by overflow-hidden with no way to view it. This commit adds interactive navigation to the whiteboard: - Auto-fit: when elements overflow, content is scaled and centered to ensure nothing is clipped (with 24px padding) - Drag-to-pan: hold and drag to pan around the whiteboard - Scroll-to-zoom: mouse wheel zooms in/out (0.2x to 5x range) - Double-click or Reset View button to return to default view - View auto-resets when new whiteboard content loads When content fits within the canvas, behavior is unchanged - no extra cursor, no transforms, no visual regression. Fixes THU-MAIC#19
7f625c8 to
65a0b9c
Compare
- Remove dead code: ?? 'Reset View' fallback (i18n key exists) - Add useMemo for elementsKey (perf optimization) - Fix el.height type narrowing (remove implicit any) - Disable pan/zoom/cursor when whiteboard is empty (UX improvement)
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.
Summary
Fixes #19 — Whiteboard content that exceeds the fixed canvas bounds was clipped by
overflow-hiddenwith no way to view hidden parts.Changes
components/whiteboard/whiteboard-canvas.tsxscale + translateto ensure all content is visible (with 24px padding). When content fits normally, no transform is applied — zero visual regression.addEventListener({ passive: false })for properpreventDefaultselect-none+preventDefaultprevents accidental text selection during drag/double-clickgrab/grabbingcursor when pan/zoom is availablelib/i18n/stage.tsresetViewtranslation key for zh-CN ("重置视图") and en-US ("Reset View")How it works
Testing
Tested with injected overflow elements (left/right/bottom + negative coordinates) and confirmed: