graflow autofit back to percent, and get tween from attr tween
This commit is contained in:
+5
-4
@@ -511,11 +511,11 @@ class BZgraflow extends Buildoz{
|
|||||||
this.fireEvent('refreshed', { })
|
this.fireEvent('refreshed', { })
|
||||||
if(this.hasAttribute('autofit')){
|
if(this.hasAttribute('autofit')){
|
||||||
const autofitAttr = this.getAttribute('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)
|
? parseFloat(autofitAttr)
|
||||||
: undefined
|
: undefined
|
||||||
if(this._canRunAutoPlace()) this.autofit(autofitTween)
|
if(this._canRunAutoPlace()) this.autofit(autofitPerc)
|
||||||
else this._scheduleLayoutWhenReady(() => this.autofit(autofitTween))
|
else this._scheduleLayoutWhenReady(() => this.autofit(autofitPerc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const onLayoutComplete = () => {
|
const onLayoutComplete = () => {
|
||||||
@@ -1332,7 +1332,7 @@ class BZgraflow extends Buildoz{
|
|||||||
return(crossLayerLinks)
|
return(crossLayerLinks)
|
||||||
}
|
}
|
||||||
|
|
||||||
autofit(tween = 0, percent=100){
|
autofit(percent=100){
|
||||||
const outwidth = Math.max(this.clientWidth, 1)
|
const outwidth = Math.max(this.clientWidth, 1)
|
||||||
const outheight = Math.max(this.clientHeight, 1)
|
const outheight = Math.max(this.clientHeight, 1)
|
||||||
let inwidth = this.nodesContainer.scrollWidth
|
let inwidth = this.nodesContainer.scrollWidth
|
||||||
@@ -1347,6 +1347,7 @@ class BZgraflow extends Buildoz{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const ratio = Math.min( (outwidth / inwidth), (outheight / inheight) ) * (percent / 100)
|
const ratio = Math.min( (outwidth / inwidth), (outheight / inheight) ) * (percent / 100)
|
||||||
|
const tween = parseInt(this.getBZAttribute('tween')) || 0
|
||||||
if(tween > 0){
|
if(tween > 0){
|
||||||
const transition = `scale ${tween}ms ease-in-out`
|
const transition = `scale ${tween}ms ease-in-out`
|
||||||
this.nodesContainer.style.transition = transition
|
this.nodesContainer.style.transition = transition
|
||||||
|
|||||||
Reference in New Issue
Block a user