Normalizing bounding boxes

This commit is contained in:
Jeff Avallone 2019-01-27 11:49:48 -05:00
parent 67d970c837
commit f71d707e23
1 changed files with 15 additions and 1 deletions

View File

@ -3,6 +3,15 @@ import ReactDOM from 'react-dom';
import nodeTypes from 'rendering/types';
const normalizeBBox = box => ({
width: 0,
height: 0,
axisY: (box.height || 0) / 2,
axisX1: 0,
axisX2: (box.width || 0),
...box
});
const layout = data => {
if (typeof data == 'string') {
return data;
@ -14,10 +23,15 @@ const layout = data => {
data.children = data.children.map(layout);
}
return nodeTypes[type].layout({
const result = nodeTypes[type].layout({
props: {},
...data
});
return {
...result,
box: normalizeBBox(result.box)
};
};
const getBBox = content => {