graflow: autofit OK
This commit is contained in:
13
bzGraflow.js
13
bzGraflow.js
@@ -629,8 +629,6 @@ class BZgraflow extends Buildoz{
|
|||||||
if(tween == null) tween = parseInt(this.getBZAttribute('tween')) || 500
|
if(tween == null) tween = parseInt(this.getBZAttribute('tween')) || 500
|
||||||
if(align == null) align = this.getBZAttribute('align') || 'center'
|
if(align == null) align = this.getBZAttribute('align') || 'center'
|
||||||
|
|
||||||
console.log('autoPlace', orientation, gapx, gapy, tween, align)
|
|
||||||
|
|
||||||
this.currentOrientation = orientation
|
this.currentOrientation = orientation
|
||||||
// Cancel any previous autoPlace() animations by bumping a token.
|
// Cancel any previous autoPlace() animations by bumping a token.
|
||||||
// moveNode() checks this token each frame and will no-op if superseded.
|
// moveNode() checks this token each frame and will no-op if superseded.
|
||||||
@@ -1147,6 +1145,17 @@ class BZgraflow extends Buildoz{
|
|||||||
return(crossLayerLinks)
|
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)
|
Buildoz.define('graflow', BZgraflow)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user