[Perf] Fix unnecessary canvas redraw (null vs undefined) (#715)

Fixes regression added in TS strict conversion. A fallback to `null`
added to match the TS type, however value being stored was actually
uncaught use of `undefined`.

`null` !== `undefined` -> redraw every frame the pointer moves
This commit is contained in:
filtered
2025-03-07 22:50:53 +11:00
committed by GitHub
parent c1af1e29d2
commit 84fad5b8a5

View File

@@ -441,7 +441,7 @@ export class LGraphCanvas implements ConnectionColorContext {
/** used for widgets */
node_widget?: [LGraphNode, IWidget] | null
/** The link to draw a tooltip for. */
over_link_center: LinkSegment | null
over_link_center?: LinkSegment
last_mouse_position: Point
/** The visible area of this canvas. Tightly coupled with {@link ds}. */
visible_area: Rect32
@@ -678,7 +678,6 @@ export class LGraphCanvas implements ConnectionColorContext {
this.current_node = null
this.node_widget = null
this.over_link_center = null
this.last_mouse_position = [0, 0]
this.visible_area = this.ds.visible_area
this.visible_links = []
@@ -2072,7 +2071,7 @@ export class LGraphCanvas implements ConnectionColorContext {
pointer.finally = () => this.dragging_canvas = false
// clear tooltip
this.over_link_center = null
this.over_link_center = undefined
return
}
}
@@ -2788,7 +2787,7 @@ export class LGraphCanvas implements ConnectionColorContext {
const segment = this.#getLinkCentreOnPos(e)
if (this.over_link_center !== segment) {
underPointer |= CanvasItem.Link
this.over_link_center = segment ?? null
this.over_link_center = segment
this.dirty_bgcanvas = true
}