From ae173f5b92d6fb86b11f91658bd357f10d9c7feb Mon Sep 17 00:00:00 2001 From: STEINNI Date: Sat, 7 Mar 2026 18:36:01 +0000 Subject: [PATCH] graflow: autofit OK --- bzGraflow.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bzGraflow.js b/bzGraflow.js index 6287edf..aff3717 100644 --- a/bzGraflow.js +++ b/bzGraflow.js @@ -629,8 +629,6 @@ class BZgraflow extends Buildoz{ if(tween == null) tween = parseInt(this.getBZAttribute('tween')) || 500 if(align == null) align = this.getBZAttribute('align') || 'center' - console.log('autoPlace', orientation, gapx, gapy, tween, align) - this.currentOrientation = orientation // Cancel any previous autoPlace() animations by bumping a token. // moveNode() checks this token each frame and will no-op if superseded. @@ -1147,6 +1145,17 @@ class BZgraflow extends Buildoz{ return(crossLayerLinks) } + autofit(){ + const parentBB = this.parentElement.getBoundingClientRect() + // Use scroll dimensions for actual content extent (nodes can extend beyond element bounds) + const contentW = Math.max(this.scrollWidth || this.offsetWidth || 1, 1) + const contentH = Math.max(this.scrollHeight || this.offsetHeight || 1, 1) + const sx = parentBB.width / contentW + const sy = parentBB.height / contentH + const scale = Math.min(sx, sy) // uniform scale to fit inside parent + this.style.transformOrigin = 'top left' + this.style.transform = `scale(${scale})` + } } Buildoz.define('graflow', BZgraflow)