Skip to content

Commit ac83918

Browse files
committed
Adjust resize logic for hidden view
Issue with some iPhones blurring the canvas after switching to code view and back. (Since recent changes to resizing to address canvas buttons.) Part of #705 AI use: Interactive session with Opus 4.8 to investigate and apply small code changes. Review and manual testing.
1 parent 0d898d1 commit ac83918

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

main/view.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ let pendingScrollBlockId = null;
2525
export function onResize(mode) {
2626
// First handle canvas and engine
2727
resizeCanvas();
28-
if (flock.engine) flock.engine.resize();
28+
// Don't resize the engine against a hidden canvas (0 width in code view);
29+
// it would collapse the render buffer. Visibility paths re-resize.
30+
const renderCanvas = document.getElementById('renderCanvas');
31+
if (flock.engine && renderCanvas && renderCanvas.clientWidth > 0) {
32+
flock.engine.resize();
33+
}
2934
// Notify listeners that layout needs updating for the new canvas size.
3035
window.dispatchEvent(new Event('flock:canvas-resize'));
3136

@@ -68,6 +73,9 @@ function resizeCanvas() {
6873
if (!canvasArea || !canvas) return;
6974

7075
const areaRect = canvasArea.getBoundingClientRect();
76+
// Hidden or collapsed (e.g. display:none in narrow-screen code view). Skip so
77+
// the buffer isn't shrunk to near-minimum; visibility paths re-resize.
78+
if (areaRect.width <= 0 || areaRect.height <= 0) return;
7179
let areaWidth = Math.max(1, Math.round(areaRect.width));
7280
let areaHeight = Math.max(1, Math.round(areaRect.height));
7381

@@ -669,7 +677,11 @@ const scrollEditingBlockIntoView = () => {
669677
let _lastViewportHeight = null;
670678

671679
const adjustViewport = () => {
672-
const viewportHeight = window.visualViewport?.height || window.innerHeight;
680+
// Under pinch/auto zoom visualViewport.height shrinks though the layout
681+
// viewport hasn't; multiply by scale so --app-height doesn't collapse. At
682+
// scale 1 this is identical to the raw height.
683+
const vv = window.visualViewport;
684+
const viewportHeight = vv ? vv.height * vv.scale : window.innerHeight;
673685
const vh = viewportHeight * 0.01;
674686
document.documentElement.style.setProperty('--vh', `${vh}px`);
675687
document.documentElement.style.setProperty('--app-height', `${viewportHeight}px`);

0 commit comments

Comments
 (0)