From f71d707e23b13869272df0136abeb9938fa2a613 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 27 Jan 2019 11:49:48 -0500 Subject: [PATCH] Normalizing bounding boxes --- src/layout.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/layout.js b/src/layout.js index d2619cf..5ad571c 100644 --- a/src/layout.js +++ b/src/layout.js @@ -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 => {