diff --git a/src/relations/Bounds.js b/src/relations/Bounds.js index 9f7f235..3ebae4b 100644 --- a/src/relations/Bounds.js +++ b/src/relations/Bounds.js @@ -93,15 +93,19 @@ const mergeBounds = clientBounds => { }; const extend = function(a, b) { - a.x = Math.min(a.x, b.x); - a.left = Math.min(a.left, b.left); - a.width = a.width + b.width; - a.right = Math.max(a.right + b.right); + const x = Math.min(a.x, b.x); + const left = Math.min(a.left, b.left); + const y = Math.max(a.y, b.y); + const right = Math.max(a.right, b.right); + const width = a.width + b.width; + + const { bottom, height, top } = a; + return { bottom, height, left, right, top, width, x, y }; }; if (previous) { if (isConsecutive(previous, bbox)) - extend(previous, bbox); + merged[merged.length - 1] = extend(previous, bbox); else merged.push(bbox); } else {