Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixing race condition
  • Loading branch information
maludwig committed Nov 3, 2025
commit 041ec32c10d22cc5a3c9ded64717a9dca7c69ef2
8 changes: 6 additions & 2 deletions src/lib/litegraph/src/CanvasPointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type { CompassCorners } from './interfaces'
import { dist2 } from './measure'
import type { CanvasPointerEvent } from './types/events'

function isWindowBlurred() {
return !document.hasFocus() || document.visibilityState !== 'visible'
}

/**
* Allows click and drag actions to be declared ahead of time during a pointerdown event.
*
Expand Down Expand Up @@ -189,8 +193,8 @@ export class CanvasPointer {
const { eDown } = this
if (!eDown) return

// No buttons down, but eDown exists - clean up & leave
if (!e.buttons) {
// Window does not have focus, so reset the pointer state.
if (isWindowBlurred()) {
this.reset()
return
}
Expand Down