Skip to content

Interaction Guards

Inside the canvas every press and wheel belongs to the flow - until an element opts out. Three CSS classes hand them back: nodrag for controls inside a node, nopan for overlays of your own, nowheel for areas that scroll. NoDragClass, NoPanClass and NoWheelClass choose the class names, or switch a guard off.

Drag me by my title
40

Select this text - the node stays put.

class="nodrag"
Scrollable log
line 01
line 02
line 03
line 04
line 05
line 06
line 07
line 08
line 09
line 10
line 11
line 12
line 13
line 14
line 15
line 16
line 17
line 18
line 19
line 20
class="nowheel"
nopan
Dragging here does not pan the canvas.
bit Blow

Try it

  • Drag the slider in the top node, or select the text under it: the node stays put and is not even selected, because that area carries the drag guard. Drag the node by its title to move it.
  • Scroll over the list in the lower node: the list scrolls and the canvas does not zoom. Scroll over the rest of the node, or the background, and the canvas zooms.
  • Drag the box at the top right: the view does not pan. Drag the empty background beside it and the view pans.
  • Pick Renamed under Guard classes: everything behaves the same, with the classes now called app-nodrag, app-nopan and app-nowheel - the labels in the nodes and the box show the class in force.
  • Pick Off: now dragging the slider drags its node, scrolling over the list zooms the canvas, and dragging the box pans - the classes are still in the markup, but nothing honours them.

How it works

  • NoDragClass ("nodrag"): a press on an element with the class, or anywhere inside one, never reaches the canvas - it does not select or drag the node and does not pan. The usual home for inputs, sliders, buttons and selectable text in a NodeTemplate.
  • NoPanClass ("nopan"): the same guard, named for overlays of your own that must not pan the canvas when dragged - here a plain div placed in the canvas's child content.
  • NoWheelClass ("nowheel"): the element keeps its wheel events, so a scrollable area inside the flow scrolls instead of zooming it.
  • Set a parameter to another name when the class clashes with your CSS, or to null to switch that guard off. Only elements inside the canvas count, so a page that wraps the whole flow in one of these classes does not switch the flow off.
  • The guards are listeners in the browser, because only the DOM knows which element an event started on; changing a parameter puts new ones up. Keys typed into an input, textarea, select or editable element always belong to it, guard or not.
An unhandled error has occurred. Reload 🗙