Compare commits

...

4 Commits

+1 -10
View File
@@ -1196,11 +1196,6 @@ 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
@@ -1229,11 +1224,7 @@ 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
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)`
this.style.transform = `scale(${scale})`
}
}
Buildoz.define('graflow', BZgraflow)