Skip to content

fix(docs): add retry backoff for SVG fit + scroll fallback in mermaid modal#139

Closed
JusterZhu wants to merge 2 commits into
mainfrom
docs/core-execution-flow
Closed

fix(docs): add retry backoff for SVG fit + scroll fallback in mermaid modal#139
JusterZhu wants to merge 2 commits into
mainfrom
docs/core-execution-flow

Conversation

@JusterZhu

Copy link
Copy Markdown
Collaborator

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 fitToScreen first reads them (returns 0). The function bailed out early and left the SVG at native size with overflow: hidden on the modal body — the user saw only a blank wall.

Fixes

  • Exponential backoff retry for fitToScreen — up to 8 attempts with increasing delays (100ms, 200ms, ..., 800ms)
  • Dimension fallback chain — viewBox → width/height attributes → getBoundingClientRect
  • Scroll fallback — changed modal body from overflow: hidden to overflow: auto, so even if panzoom fails, users can always scroll to see the diagram
  • Drop unused variables in wheel handler

🤖 Generated with Claude Code

… 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>
Copilot AI review requested due to automatic review settings June 21, 2026 07:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…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>
@JusterZhu

Copy link
Copy Markdown
Collaborator Author

Superseded by the new approach in the next PR.

@JusterZhu JusterZhu closed this Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants