fix(docs): add retry backoff for SVG fit + scroll fallback in mermaid modal#139
Closed
JusterZhu wants to merge 2 commits into
Closed
fix(docs): add retry backoff for SVG fit + scroll fallback in mermaid modal#139JusterZhu wants to merge 2 commits into
JusterZhu wants to merge 2 commits into
Conversation
… modal Large mermaid diagrams like 'ClientStrategy Execution Flow' generate wide SVGs (2000+px). On open, fitToScreen sometimes reads 0 from viewBox because the DOM layout isn't done yet, bailing out early. This left the SVG at native size with overflow:hidden — invisible. Fixes: - Exponential backoff retry for fitToScreen (up to 8 attempts) - Fallback to width/height attributes then getBoundingClientRect - Changed modal body from overflow:hidden to overflow:auto for scroll fallback when panzoom hasn't fitted yet - Wrapped SVG in .svgWrapper for clean DOM interaction Co-Authored-By: Claude <noreply@anthropic.com>
…nd drag-to-scroll Replace panzoom-based modal with a simpler, more reliable approach: - Click inline diagram to open a fullscreen modal - + / - buttons step through zoom levels - 1:1 reset button and current zoom % display - Drag-to-scroll (pan) via scrollLeft/scrollTop (no panzoom) - Two-layer wrapper: * Outer: explicit px size = natural × scale → correct scroll range * Inner: transform:scale() at natural dimensions → fills outer - Esc to close, locked body scroll - Dark theme support throughout Removes @panzoom/panzoom dependency. Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
Author
|
Superseded by the new approach in the next PR. |
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.
Problem
After the panzoom modal (PRs #136, #137, #138), large mermaid diagrams like "ClientStrategy Execution Flow" (全流程总图) were invisible when opening the modal.
Root cause: For large complex diagrams, the SVG viewBox dimensions are sometimes not ready when
fitToScreenfirst reads them (returns 0). The function bailed out early and left the SVG at native size withoverflow: hiddenon the modal body — the user saw only a blank wall.Fixes
fitToScreen— up to 8 attempts with increasing delays (100ms, 200ms, ..., 800ms)overflow: hiddentooverflow: auto, so even if panzoom fails, users can always scroll to see the diagram🤖 Generated with Claude Code