Skip to content

Commit

Permalink
fix: trigger resize can't update node
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Nov 20, 2024
1 parent d6d3fe1 commit b4c086e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/primitives/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function getSafeText(c: CanvasRenderingContext2D, text: string, width: nu

export function resetLayout(treemap: TreemapLayout, w: number, h: number) {
treemap.layoutNodes = squarify(treemap.data, { w, h, x: 0, y: 0 }, treemap.decorator.layout)
treemap.reset()
treemap.reset(true)
}

export class TreemapLayout extends etoile.Schedule {
Expand Down Expand Up @@ -163,21 +163,22 @@ export class TreemapLayout extends etoile.Schedule {
}
}

reset() {
reset(refresh = false) {
this.remove(this.bgLayer, this.fgBox)
if (!this.bgLayer.__refresh__) {
this.bgLayer.destory()
for (const node of this.layoutNodes) {
this.drawBackgroundNode(node)
}
}
if (this.fgBox.elements.length) {
this.fgBox = this.fgBox.clone()
} else {
if (!this.fgBox.elements.length || refresh) {
this.render.ctx.textBaseline = 'middle'
this.fgBox.destory()
for (const node of this.layoutNodes) {
this.drawForegroundNode(node)
}
} else {
this.fgBox = this.fgBox.clone()
}
this.add(this.bgLayer, this.fgBox)
}
Expand Down

0 comments on commit b4c086e

Please sign in to comment.