@neo4j-nvl/layout-workers
Version:
Layout workers for the Neo4j Visualization Library
24 lines (23 loc) • 812 B
JavaScript
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable no-empty-function */
import { layout } from './dagre-layout-impl.js';
class HierarchicalLayoutFallbackWorker {
start() { }
postMessage(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(() => {
this.onmessage({ data: layoutData });
}, forcedDelay);
}
else {
this.onmessage({ data: layoutData });
}
}
onmessage() { }
close() { }
}
export const hierarchicalLayoutFallbackWorker = {
port: new HierarchicalLayoutFallbackWorker()
};