@rxflow/manhattan
Version:
Manhattan routing algorithm for ReactFlow - generates orthogonal paths with obstacle avoidance
36 lines (33 loc) • 886 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getNodeDimensions = getNodeDimensions;
exports.getNodePosition = getNodePosition;
/**
* Node dimensions interface
*/
/**
* Get node dimensions following ReactFlow's internal logic
* Priority: measured > direct property > initialWidth/Height > 0
*
* @param node - ReactFlow internal node
* @returns Node dimensions with width and height
*/
function getNodeDimensions(node) {
const width = node.measured?.width ?? node.width ?? node.initialWidth ?? 0;
const height = node.measured?.height ?? node.height ?? node.initialHeight ?? 0;
return {
width,
height
};
}
/**
* Get node absolute position from internals
*
* @param node - ReactFlow internal node
* @returns Absolute position { x, y }
*/
function getNodePosition(node) {
return node.internals.positionAbsolute;
}