graflow autofit back to percent, and get tween from attr tween

This commit is contained in:
STEINNI
2026-07-30 14:05:33 +00:00
parent 9b0cb2582e
commit 7471a37220
+5 -4
View File
@@ -511,11 +511,11 @@ class BZgraflow extends Buildoz{
this.fireEvent('refreshed', { })
if(this.hasAttribute('autofit')){
const autofitAttr = this.getAttribute('autofit')
const autofitTween = (autofitAttr !== null && autofitAttr !== '' && !Number.isNaN(parseFloat(autofitAttr)))
const autofitPerc = (autofitAttr !== null && autofitAttr !== '' && !Number.isNaN(parseFloat(autofitAttr)))
? parseFloat(autofitAttr)
: undefined
if(this._canRunAutoPlace()) this.autofit(autofitTween)
else this._scheduleLayoutWhenReady(() => this.autofit(autofitTween))
if(this._canRunAutoPlace()) this.autofit(autofitPerc)
else this._scheduleLayoutWhenReady(() => this.autofit(autofitPerc))
}
}
const onLayoutComplete = () => {
@@ -1332,7 +1332,7 @@ class BZgraflow extends Buildoz{
return(crossLayerLinks)
}
autofit(tween = 0, percent=100){
autofit(percent=100){
const outwidth = Math.max(this.clientWidth, 1)
const outheight = Math.max(this.clientHeight, 1)
let inwidth = this.nodesContainer.scrollWidth
@@ -1347,6 +1347,7 @@ class BZgraflow extends Buildoz{
return
}
const ratio = Math.min( (outwidth / inwidth), (outheight / inheight) ) * (percent / 100)
const tween = parseInt(this.getBZAttribute('tween')) || 0
if(tween > 0){
const transition = `scale ${tween}ms ease-in-out`
this.nodesContainer.style.transition = transition