Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

A re-layout must not teleport the canvas view (#227)

nyblnetff8d6e005a8e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 15ef92cf..018afa66 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,15 @@ pre-1.0.
## [Unreleased]
+- **Fix: the slide could open off-centre, pushed to one side and clipped.**
+ Most likely on a deck whose page is larger than the default — a 1600×900 deck
+ outgrows the editing canvas at zoom levels where a 1280×720 one still fits.
+ The canvas gained room to pan past the slide's edges in 1.0.14, and turning
+ that room on moved the slide within the scrollable area without moving the
+ view with it, so you were left looking at the empty margin beside your slide.
+ Clicking the zoom percentage snapped it back, because that was the one action
+ that re-centred. The view now stays put across any re-layout.
+
## [1.0.15] — 2026-08-03
- **Fix: removing a formatting option no longer disconnects the people you are
diff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.ts
index 8103fbb6..38835226 100644
--- a/slides/src/editor/canvas.ts
+++ b/slides/src/editor/canvas.ts
@@ -332,7 +332,19 @@ export class SlideCanvas {
// box, so writing padding here cannot disturb the fitScale computed above.
const padX = width * this.scale > availW ? Math.round(this.scroller.clientWidth / 2) : 0
const padY = height * this.scale > availH ? Math.round(this.scroller.clientHeight / 2) : 0
+ // Changing the pan room moves the stage within the scroll canvas by exactly
+ // that much, so changing it without compensating TELEPORTS the view. The
+ // first relayout that turns padding on leaves the scroll at 0 — which is now
+ // half a viewport of empty canvas, with the slide shoved off to the side and
+ // clipped. setZoom re-centres afterwards and hid this; every OTHER route in
+ // (opening a deck whose stage already overflows, a window resize, toggling a
+ // panel) does not. Reported on a 1600x900 deck, whose stage outgrows the
+ // canvas at ordinary zooms where the 1280x720 default still fits.
+ const wasX = parseFloat(this.scroller.style.paddingLeft) || 0
+ const wasY = parseFloat(this.scroller.style.paddingTop) || 0
this.scroller.style.padding = padX || padY ? `${padY}px ${padX}px` : ''
+ if (padX !== wasX) this.scroller.scrollLeft += padX - wasX
+ if (padY !== wasY) this.scroller.scrollTop += padY - wasY
this.scaleHost.style.transform = `scale(${this.scale})`
this.moveable.zoom = 1 / this.scale
this.moveable.updateRect()