Loading
fix: panner viewport rectangle accounts for cssScale and letterbox
The previous formula divided panX/panY directly by zoom, ignoring that
pan values are CSS pixels while the canvas buffer is 800 px wide rendered
at width:100%. This caused the yellow viewport rectangle to drift from
the actual visible region as soon as the canvas CSS width differed from
800 px (i.e. always).
Correct derivation:
bxMin = -panX / (zoom * cssScale) (leftmost visible buffer pixel)
panoX = (bxMin - lb.dx) * (cv.width / lb.dw)
where cssScale = canvasMain.clientWidth / canvasMain.width and lb is the
letterbox rect. The same applies to the vertical axis.
Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>