You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
674 B

4 months ago
/**
* Get average height or height for node's position calculation, according to align.
* @param {*} preNode previous node
* @param {*} node current node, whose position is going to be calculated
* @param {'center' | undefined} align 'center' means nodes align at the center, other value means align at the left-top
* @param {string} heightField field name for height value on preNode and node
* @return {number} the height for calculation
*/
function getHeight(preNode, node, align, heightField = 'height') {
return align === 'center' ? (preNode[heightField] + node[heightField]) / 2 : preNode.height;
}
module.exports = {
assign: Object.assign,
getHeight
};