aboutsummaryrefslogtreecommitdiff
path: root/src/fields/Doc.ts
diff options
context:
space:
mode:
authorsrichman333 <sarah_n_richman@brown.edu>2023-11-06 18:36:58 -0500
committersrichman333 <sarah_n_richman@brown.edu>2023-11-06 18:36:58 -0500
commit1b412d402c77a2aae82cf86b1f6a23f8a4f82caf (patch)
tree7ebd22eeade12099d1d891d9f9b264f02956ad4a /src/fields/Doc.ts
parent7163062edec37cef9dd9ae6c123d987e83837463 (diff)
parenta4e3b645317c4589cf49f8007f6e6b57cf2c12d3 (diff)
Merge branch 'master' into dataViz-annotations
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r--src/fields/Doc.ts16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 9e3eb28f9..feacdc9c5 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -687,16 +687,12 @@ export namespace Doc {
*/
export function ComputeContentBounds(docList: Doc[]) {
const bounds = docList.reduce(
- (bounds, doc) => {
- const [sptX, sptY] = [NumCast(doc.x), NumCast(doc.y)];
- const [bptX, bptY] = [sptX + doc[Width](), sptY + doc[Height]()];
- return {
- x: Math.min(sptX, bounds.x),
- y: Math.min(sptY, bounds.y),
- r: Math.max(bptX, bounds.r),
- b: Math.max(bptY, bounds.b),
- };
- },
+ (bounds, doc) => ({
+ x: Math.min(NumCast(doc.x), bounds.x),
+ y: Math.min(NumCast(doc.y), bounds.y),
+ r: Math.max(NumCast(doc.x) + doc[Width](), bounds.r),
+ b: Math.max(NumCast(doc.y) + doc[Height](), bounds.b),
+ }),
{ x: Number.MAX_VALUE, y: Number.MAX_VALUE, r: -Number.MAX_VALUE, b: -Number.MAX_VALUE }
);
return bounds;