Skip to content

Node Drag Threshold

NodeDragThreshold is how far, in screen pixels, the pointer has to travel before a press on a node starts moving it. A higher threshold keeps a shaky click from nudging nodes out of place; the line above the canvas tells you what each gesture did.

last gesture: -
Drag me a little, then a lot
Node 2
Node 3
bit Blow

Try it

  • Click a node without moving the pointer: it is selected, stays put, and counts as a click.
  • Press a node and move the pointer a little - less than the threshold - before letting go: the node is selected but does not move. Past a few pixels it no longer counts as a click either.
  • Drag a node further than the threshold: it stays put until the pointer has travelled that far, then catches up with the pointer and follows it.
  • Move Threshold down to 0 or 1 and every small wobble moves the node; move it up to 80 and only a deliberate drag does.
  • Press Escape in the middle of a drag: the node goes back to where it started.

How it works

  • NodeDragThreshold (default 1) is measured from the point where the node was pressed, in screen pixels, so it feels the same at any zoom. Until the pointer has gone that far the node is not moved.
  • NodeClickDistance (default 3) is how far the pointer may travel and still count as a click: beyond it OnNodeClick is not raised. A gesture between the two distances neither moves the node nor clicks it.
  • OnNodeDragStart is raised when the node is pressed and OnNodeDragStop when it is let go, whether or not it moved; the page compares the node's Position at the two to tell a move from a press.
  • OnNodeClick is raised after the release, for a press that stayed within NodeClickDistance.
  • The node is selected on the press itself, which is why it selects whatever the threshold.
An unhandled error has occurred. Reload 🗙