Switch to onDrawForeground

This commit is contained in:
Benjamin Lu
2025-09-18 14:44:08 -07:00
parent da3a467f61
commit 20eb500020

View File

@@ -31,12 +31,12 @@ function buildContext(canvas: LGraphCanvas): LinkRenderContext {
} }
export function attachSlotLinkPreviewRenderer(canvas: LGraphCanvas) { export function attachSlotLinkPreviewRenderer(canvas: LGraphCanvas) {
const originalOnRender = canvas.onRender?.bind(canvas) const originalOnDrawForeground = canvas.onDrawForeground?.bind(canvas)
const patched = ( const patched = (
canvasElement: HTMLCanvasElement, ctx: CanvasRenderingContext2D,
ctx: CanvasRenderingContext2D area: LGraphCanvas['visible_area']
) => { ) => {
originalOnRender?.(canvasElement, ctx) originalOnDrawForeground?.(ctx, area)
const { state } = useSlotLinkDragState() const { state } = useSlotLinkDragState()
if (!state.active || !state.source) return if (!state.active || !state.source) return
@@ -59,7 +59,6 @@ export function attachSlotLinkPreviewRenderer(canvas: LGraphCanvas) {
const colour = resolveConnectingLinkColor(sourceSlot?.type) const colour = resolveConnectingLinkColor(sourceSlot?.type)
ctx.save() ctx.save()
canvas.ds.toCanvasContext(ctx)
linkRenderer.renderDraggingLink( linkRenderer.renderDraggingLink(
ctx, ctx,
@@ -74,7 +73,7 @@ export function attachSlotLinkPreviewRenderer(canvas: LGraphCanvas) {
ctx.restore() ctx.restore()
} }
canvas.onRender = patched canvas.onDrawForeground = patched
} }
function resolveSourceSlot( function resolveSourceSlot(