Skip to content

Interactions Playground

The canvas parameters that change its gestures - snapping, click-to-connect, drag-to-select, scroll-to-pan, double-click zoom and culling - as live switches, the methods you call on a captured BlowCanvas as buttons, and an event log of what the canvas raises while you work.

reconnect me
Input
Node 2
Node 3
Output
Arrow keys move the view, Home shows the whole flow.
bit Blow
Event log · selected: 0

Try it

  • Tick Snap to grid and drag a node: it jumps from dot to dot of the background, and each arrow-key press moves a selected node one dot.
  • Tick Connect on click, then click a handle and click another node's handle: the two are connected without a drag. Clicking empty space or pressing Escape abandons it.
  • Tick Selection on drag: a plain drag on the background now draws a selection box; hold Space while dragging to pan instead. Without it, Shift+drag draws the box.
  • Tick Pan on scroll: the wheel or trackpad now pans the view (Shift turns it sideways), and Ctrl+wheel still zooms.
  • Untick Zoom on double-click: double-clicking the background no longer zooms in.
  • Tick Cull off-screen and pan a node out of view: it is no longer rendered at all - the browser's element inspector shows it gone - and comes back as soon as it is in view again.
  • Click an edge to select it, then drag the dot at either end onto another handle to reconnect it.
  • Double-click or right-click a node (or focus it and press Shift+F10), drag one, connect two or change the selection, and watch each event arrive at the top of the log; the log's title counts what is selected.
  • Add node, Delete selected, Fit view, Zoom 1.5× and Export call the canvas from code; Export logs how many nodes and edges a snapshot holds and its zoom.

How it works

  • SnapToGrid snaps dragged positions to a SnapGridX by SnapGridY grid (15 by 15 by default; 20 here, the background's Gap, so the dots show the grid). The same grid sets the arrow keys' step.
  • ConnectOnClick (off) adds click-a-handle, click-another to dragging. SelectionOnDrag (off) makes a plain pane drag box-select, with PanActivationKey (Space) to pan; SelectionKey (Shift) box-selects either way.
  • PanOnScroll (off) makes the wheel pan instead of zoom; ZoomOnDoubleClick is on by default; OnlyRenderVisibleElements (off) renders only the nodes and edges in view, for large graphs.
  • An edge is reconnectable while EdgesReconnectable (on) and its own Reconnectable are; OnReconnect reports the new wiring and the edge keeps its id.
  • The log comes from OnConnectStart, OnConnect and OnConnectEnd, OnReconnect, OnSelectionChange, OnNodeDoubleClick, OnNodeContextMenu (handling it suppresses the browser's menu), OnNodeDragStop and OnDelete, which reports a deletion by key and by button alike.
  • The buttons use the canvas captured with @ref: AddNodes, DeleteElementsAsync with the selected nodes and edges, FitView(), ZoomTo(1.5) and ToObject(), which returns a BlowSnapshot of the nodes, edges and viewport.
  • Both control groups are BlowPanels inside the canvas, so they stay put while the graph pans and zooms, and the minimap is Pannable (its default): click or drag in it to move the view. The edges show Animated, an arrowhead at each end (MarkerStart with ArrowClosed) and a SmoothStep path.
An unhandled error has occurred. Reload 🗙