UNPKG

@neo4j-nvl/layout-workers

Version:

Layout workers for the Neo4j Visualization Library

17 lines (16 loc) 575 B
import { layout } from './dagre-layout-impl.js'; onconnect = ({ ports }) => { const port = ports[0]; port.onmessage = ({ data }) => { const { nodes, nodeIds, idToPosition, rels, direction, packing, pixelRatio, forcedDelay = 0 } = data; const layoutData = layout(nodes, nodeIds, idToPosition, rels, direction, packing, pixelRatio); if (forcedDelay) { setTimeout(() => { port.postMessage(layoutData); }, forcedDelay); } else { port.postMessage(layoutData); } }; };