You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(mermaid): use CSS zoom instead of transform for scroll-safe zooming
Replace transform: scale() with CSS zoom property for Mermaid diagram
zoom controls. Transform only changes visual appearance while the layout
box stays fixed, causing content that expands upward/leftward to go into
unscrollable negative space. CSS zoom changes actual layout size so
overflow scrolls normally in all directions.
- Change align-items: flex-start to center for vertical centering
- Add min-height: 400px to prevent diagram compression
- Add initial zoom: 1.4 for better default readability
- Remove unnecessary mermaid-inner wrapper
- Update INITIAL_ZOOM constant in JavaScript
- Update Scaling Small Diagrams section to use zoom
- Remove dead code (transition on non-animatable property)
Copy file name to clipboardExpand all lines: CHANGELOG.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,16 @@
1
1
# Changelog
2
2
3
+
## [0.4.3] - 2026-03-01
4
+
5
+
### Mermaid Zoom and Positioning Fixes
6
+
-**Fixed zoom clipping**: Replaced `transform: scale()` with CSS `zoom` property. Transform only changes visual appearance — content expanding upward/leftward goes into negative space which can't be scrolled to. Zoom changes actual layout size, so overflow scrolls normally in all directions.
7
+
-**Fixed vertical centering**: Changed `align-items: flex-start` to `align-items: center` so diagrams are centered both horizontally and vertically in their container.
8
+
-**Added initial zoom**: Complex diagrams can start at zoom > 1 (e.g., 1.4x) for better readability while keeping zoom controls functional.
9
+
-**Added min-height**: Containers now have `min-height: 400px` to prevent vertical flowcharts from compressing into unreadable thumbnails.
10
+
- Removed unnecessary `.mermaid-inner` wrapper — no longer needed with zoom-based approach.
11
+
- Updated JavaScript to use `INITIAL_ZOOM` constant for consistent reset behavior.
12
+
- Updated "Scaling Small Diagrams" section to use `zoom` instead of `transform: scale()` for consistency.
CSS `transform: scale()` only changes visual appearance — the element's layout box stays the same size. When you scale from `center center`, content expands upward and leftward into negative coordinate space. Scroll containers can't scroll to negative positions, so the top and left of the zoomed content get clipped.
547
+
548
+
CSS `zoom` actually changes the element's layout size. The content grows downward and rightward like any other growing element, staying fully scrollable.
549
+
534
550
### HTML
535
551
536
552
```html
@@ -552,28 +568,23 @@ Add zoom controls to every `.mermaid-wrap` container for complex diagrams.
552
568
Add once at the end of the page. Handles button clicks and scroll-to-zoom on all `.mermaid-wrap` containers:
553
569
554
570
```javascript
555
-
functionupdateZoomState(wrap) {
556
-
var target =wrap.querySelector('.mermaid');
557
-
var zoom =parseFloat(target.dataset.zoom||'1');
558
-
wrap.classList.toggle('is-zoomed', zoom >1);
559
-
}
571
+
// Match this to the CSS zoom value (or 1 if not set)
572
+
varINITIAL_ZOOM=1.4;
560
573
561
574
functionzoomDiagram(btn, factor) {
562
575
var wrap =btn.closest('.mermaid-wrap');
563
576
var target =wrap.querySelector('.mermaid');
564
-
var current =parseFloat(target.dataset.zoom||'1');
565
-
var next =Math.min(Math.max(current * factor, 0.3), 5);
577
+
var current =parseFloat(target.dataset.zoom||INITIAL_ZOOM);
578
+
var next =Math.min(Math.max(current * factor, 0.5), 5);
Scroll-to-zoom requires Ctrl/Cmd+scroll to avoid hijacking normal page scroll. Click-and-drag panning activates only when zoomed in (zoom > 1). Cursor changes to `grab`/`grabbing` to signal the behavior. The zoom range is capped at 0.3x–5x.
624
+
Scroll-to-zoom requires Ctrl/Cmd+scroll to avoid hijacking normal page scroll. Cursor changes to `grab`/`grabbing` to signal pan mode. The zoom range is capped at 0.5x–5x.
0 commit comments