diff options
| author | yipstanley <stanley_yip@brown.edu> | 2019-07-03 12:12:48 -0400 | 
|---|---|---|
| committer | yipstanley <stanley_yip@brown.edu> | 2019-07-03 12:12:48 -0400 | 
| commit | 226ef5557464f7d446e3bf36d592b85990e41a87 (patch) | |
| tree | f9d592a81521233c543cd28a9c3d20daa9d38bf1 /src/new_fields/Doc.ts | |
| parent | 6c5468eee0ec59d4ddaf116e67d067b567ccb87a (diff) | |
| parent | c619bad0281ea6f248c48b8d418f324f67f530dd (diff) | |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/new_fields/Doc.ts')
| -rw-r--r-- | src/new_fields/Doc.ts | 12 | 
1 files changed, 12 insertions, 0 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 734a90731..29d35e19f 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -249,6 +249,18 @@ export namespace Doc {          return true;      } +    export function ComputeContentBounds(doc: Doc) { +        let bounds = DocListCast(doc.data).reduce((bounds, doc) => { +            var [sptX, sptY] = [NumCast(doc.x), NumCast(doc.y)]; +            let [bptX, bptY] = [sptX + doc[WidthSym](), sptY + doc[HeightSym]()]; +            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) +            }; +        }, { x: Number.MAX_VALUE, y: Number.MAX_VALUE, r: Number.MIN_VALUE, b: Number.MIN_VALUE }); +        return bounds; +    } +      //      // Resolves a reference to a field by returning 'doc' if o field extension is specified,      // otherwise, it returns the extension document stored in doc.<fieldKey>_ext.  | 
