Normalizing bounding boxes
This commit is contained in:
parent
67d970c837
commit
f71d707e23
@ -3,6 +3,15 @@ import ReactDOM from 'react-dom';
|
|||||||
|
|
||||||
import nodeTypes from 'rendering/types';
|
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 => {
|
const layout = data => {
|
||||||
if (typeof data == 'string') {
|
if (typeof data == 'string') {
|
||||||
return data;
|
return data;
|
||||||
@ -14,10 +23,15 @@ const layout = data => {
|
|||||||
data.children = data.children.map(layout);
|
data.children = data.children.map(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeTypes[type].layout({
|
const result = nodeTypes[type].layout({
|
||||||
props: {},
|
props: {},
|
||||||
...data
|
...data
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...result,
|
||||||
|
box: normalizeBBox(result.box)
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getBBox = content => {
|
const getBBox = content => {
|
||||||
|
Loading…
Reference in New Issue
Block a user