Graflow: autofit readded translations

This commit is contained in:
STEINNI
2026-04-13 15:23:15 +00:00
parent 7d3548d597
commit cfe33b8111
+10 -1
View File
@@ -1196,6 +1196,11 @@ class BZgraflow extends Buildoz{
autofit(percent=100){
if(!this.parentElement) return
const prevTransformOrigin = this.style.transformOrigin
this.style.transform = 'none'
this.style.transformOrigin = 'top left'
// Measure real content by unioning viewport-space bounding boxes.
// This is robust with overflow:auto and absolute-positioned layers.
let left = Infinity
@@ -1224,7 +1229,11 @@ class BZgraflow extends Buildoz{
const sx = parentBB.width / contentW
const sy = parentBB.height / contentH
const scale = Math.min(sx, sy)*(percent/100) // uniform scale to fit inside parent
this.style.transform = `scale(${scale})`
const tx = Number.isFinite(left) ? (-left + gapx) : gapx
const ty = Number.isFinite(top) ? (-top + gapy) : gapy
this.style.transformOrigin = prevTransformOrigin || 'top left'
// First normalize content origin to (0,0), then scale to fit.
this.style.transform = `scale(${scale}) translate(${tx}px, ${ty}px)`
}
}
Buildoz.define('graflow', BZgraflow)