Skip to content

Commit

Permalink
fix: cache state check
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Feb 3, 2025
1 parent 2c46916 commit 4d07d6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/primitives/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ export class RenderCache extends Canvas implements Cache {
if (width * a >= size || height * d >= size) {
return
}
if (width * a * height * d >= size * size) {
return
}
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)
this.setOptions({ width: width * a, height: height * d, devicePixelRatio })
resetLayout(treemap, width * a, height * d)
drawGraphIntoCanvas(treemap, { c: this.canvas, ctx: this.ctx, dpr: devicePixelRatio })
this.$memory = true
if (this.ctx.isContextLost()) {
this.$memory = false
}
}
destroy() {
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)
Expand Down
3 changes: 3 additions & 0 deletions src/primitives/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ export class TreemapEvent extends DOMEvent {
private onwheel(ctx: TreemapEventContext, metadata: DOMEventMetadata<'wheel'>) {
ctx.treemap.renderCache.destroy()

ctx.treemap.event.silent(INTERNAL_EVENT_MAPPINGS.ON_ZOOM)

const { native } = metadata
const { treemap } = ctx
// @ts-expect-error safe
Expand Down Expand Up @@ -339,6 +341,7 @@ export class TreemapEvent extends DOMEvent {
this.exposedEvent.active('mousemove')
this.active('click')
this.exposedEvent.active('click')
treemap.event.active(INTERNAL_EVENT_MAPPINGS.ON_ZOOM)
}
})
}
Expand Down

0 comments on commit 4d07d6c

Please sign in to comment.