1 | const { mix } = require('@antv/util');
|
2 |
|
3 | /**
|
4 | * Get average height or height for node's position calculation, according to align.
|
5 | * @param {*} preNode previous node
|
6 | * @param {*} node current node, whose position is going to be calculated
|
7 | * @param {'center' | undefined} align 'center' means nodes align at the center, other value means align at the left-top
|
8 | * @param {string} heightField field name for height value on preNode and node
|
9 | * @return {number} the height for calculation
|
10 | */
|
11 | function getHeight(preNode, node, align, heightField = 'height') {
|
12 | return align === 'center' ? (preNode[heightField] + node[heightField]) / 2 : preNode.height;
|
13 | }
|
14 |
|
15 | module.exports = {
|
16 | assign: mix,
|
17 | getHeight
|
18 | };
|