Node Type Change
A node's Type can change at runtime: set it, and the node is drawn again with the new type's look and handles. Edges whose handle went away are kept, drawn to the middle of the side the handle was on, and attach again when it comes back.
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
- Pick input: node 2 loses its target handle and takes the input border colour. The edge from Input is kept, and now ends at the middle of node 2's top side, where the handle was.
- Pick output: the source handle goes instead, the border takes the output colour, and the edge to Output starts from the middle of node 2's bottom side.
- Pick default again: both handles are back and both edges attach to them.
How it works
Typeis a plain property: the list sets_node2.Type, this page re-renders, and the canvas draws node 2 with the built-in renderer for its new type -inputhas only a source handle,outputonly a target handle,defaultboth.- The node element's class follows the type (
bit-blow-node-input,bit-blow-node-output), which is where the coloured borders come from. - The canvas measures the nodes again after the render that follows, so the edges re-anchor to the handles that are left with no
UpdateNodeInternalscall. - An edge naming a handle its node no longer has stays in
Edges. Its end is drawn to the middle of the node'sTargetPositionorSourcePositionside, and no error is raised.