in web/js/input.js [173:211]
function down(graph, poz) {
// console.info("down", poz)
if (!isGraphValid(graph)) return
// On mouse down, if we are on a node, mark it as down.
// We will check this in move() to see if it's being dragged.
let downNodeId
for (const node of graph.data.nodes) {
if (webUtil.hitTest(graph, node.x, node.y, graph.NODE_RADIUS, poz.x, poz.y)) {
node.down = true
downNodeId = node.id
break
}
}
for (const node of graph.data.nodes) {
if (node.id !== downNodeId) node.down = false
}
let hitEdge
for (const edge of graph.data.edges) {
if (webUtil.hitTestEdge(graph, edge, poz.x, poz.y)) {
hitEdge = edge
break
}
}
if (downNodeId || hitEdge) return
// Start dragging the canvas
const ctx = graph.canvas.getContext("2d")
const transform = ctx.getTransform()
graph.canvasDrag = {
start: poz,
transform,
}
// console.log(`Start dragging at ${poz.x} ${poz.y}`)
}