From a967576d4b460c91bc7c9a6501ad6d4037a9d3be Mon Sep 17 00:00:00 2001 From: STEINNI Date: Sat, 7 Mar 2026 18:36:01 +0000 Subject: [PATCH] graflow: autofit OK --- app/assets/html/test4.html | 60 ++++++++++++++++++++--------- app/thirdparty/buildoz/bzGraflow.js | 13 ++++++- 2 files changed, 52 insertions(+), 21 deletions(-) diff --git a/app/assets/html/test4.html b/app/assets/html/test4.html index 0c0cbd1..ba91824 100644 --- a/app/assets/html/test4.html +++ b/app/assets/html/test4.html @@ -49,6 +49,14 @@ border: 2px solid black; } bz-graflow.icmp{ grid-column: 1 / -1; width: 100vw; height: 80vh; background: var(--eicui-base-color-grey-10); } + .container { + resize: both; + overflow: auto; /* required in practice */ + min-width: 800px; + min-height: 300px; + border: 1px solid #999; + padding: 1rem; + } - -
- - - - -
-
-
+
+ +
+ + + + +
+
+
+
diff --git a/app/thirdparty/buildoz/bzGraflow.js b/app/thirdparty/buildoz/bzGraflow.js index 6287edf..aff3717 100644 --- a/app/thirdparty/buildoz/bzGraflow.js +++ b/app/thirdparty/buildoz/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)