function move()

in web/js/input.js [37:115]


function move(graph, poz) {

    // console.info("move", poz)
    
    if (!isGraphValid(graph)) return

    const scale = graph.scale

    // Check to see if we are dragging the canvas itself
    if (graph.canvasDrag) {
        const xOffset = poz.x - graph.canvasDrag.start.x
        const yOffset = poz.y - graph.canvasDrag.start.y
        graph.offset.x = xOffset * scale + graph.canvasDrag.transform.e
        graph.offset.y = yOffset * scale + graph.canvasDrag.transform.f
        render(graph, false)
        return
    }

    // Check to see if we are dragging a node
    for (const node of graph.data.nodes) {
        if (node.down) {
            graph.canvas.style.cursor = "grab"
            node.x = poz.x - graph.offset.x / scale
            node.y = poz.y - graph.offset.y / scale
            render(graph, false)
            return // Don't continue to hover processing
        }
    }

    let changed = false

    // Check for mouse over nodes
    let hitId = null
    for (const node of graph.data.nodes) {
        if (webUtil.hitTest(graph, node.x, node.y, graph.NODE_RADIUS, poz.x, poz.y)) {
            if (!node.hover) changed = true
            node.hover = true
            hitId = node.id
            graph.canvas.style.cursor = "pointer"
        }
    }
    for (const node of graph.data.nodes) {
        if (node.id !== hitId) {
            if (node.hover) changed = true
            node.hover = false
        }
    }
    if (hitId) {
        if (changed) render(graph, false)
        return // Don't continue to hover edges that might be underneath
    }

    // Check for mouse over edges
    hitId = null
    for (const edge of graph.data.edges) {
        if (webUtil.hitTestEdge(graph, edge, poz.x, poz.y)) {
            if (!edge.hover) changed = true
            edge.hover = true
            hitId = edge.id
            graph.canvas.style.cursor = "pointer"
        }
    }
    for (const edge of graph.data.edges) {
        if (edge.id !== hitId) {
            if (edge.hover) changed = true
            edge.hover = false
        }
    }

    // TODO: For better performance, only render if something changed

    if (!hitId) {
        graph.canvas.style.cursor = "grab"
    }

    if (changed) {
        render(graph, false)
    }
}