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.
nopan
Dragging here does not pan the canvas.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry 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 aNodeTemplate.NoPanClass("nopan"): the same guard, named for overlays of your own that must not pan the canvas when dragged - here a plaindivplaced 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
nullto 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.