diff options
| author | bob <bcz@cs.brown.edu> | 2020-01-13 16:48:45 -0500 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2020-01-13 16:48:45 -0500 |
| commit | 9e18edc6c2b178d9d0960aa95d2b2a9f198ab6d1 (patch) | |
| tree | 6edfde1a9b4121fb8281f587444110dd45cd3c64 /src/Utils.ts | |
| parent | 9955ff8c2de58cfe37e02d6a356b5a8a2930bb05 (diff) | |
fixed onChildClick handlers to work for freeform views. added padding for fitTocontents views. fixed performance with templates. added openOnRight script func. switched filter to ||,
Diffstat (limited to 'src/Utils.ts')
| -rw-r--r-- | src/Utils.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index 04fe6750b..562d9d83f 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -328,8 +328,8 @@ export function timenow() { return now.toLocaleDateString() + ' ' + h + ':' + m + ' ' + ampm; } -export function aggregateBounds(boundsList: { x: number, y: number, width: number, height: number }[]) { - return boundsList.reduce((bounds, b) => { +export function aggregateBounds(boundsList: { x: number, y: number, width: number, height: number }[], xpad: number, ypad: number) { + let bounds = boundsList.reduce((bounds, b) => { const [sptX, sptY] = [b.x, b.y]; const [bptX, bptY] = [sptX + b.width, sptY + b.height]; return { @@ -337,6 +337,7 @@ export function aggregateBounds(boundsList: { x: number, y: number, width: numbe r: Math.max(bptX, bounds.r), b: Math.max(bptY, bounds.b) }; }, { x: Number.MAX_VALUE, y: Number.MAX_VALUE, r: -Number.MAX_VALUE, b: -Number.MAX_VALUE }); + return { x: bounds.x !== Number.MAX_VALUE ? bounds.x - xpad : bounds.x, y: bounds.y !== Number.MAX_VALUE ? bounds.y - ypad : bounds.y, r: bounds.r !== -Number.MAX_VALUE ? bounds.r + 2 * xpad : bounds.r, b: bounds.b !== -Number.MAX_VALUE ? bounds.b + 2 * ypad : bounds.b } } export function intersectRect(r1: { left: number, top: number, width: number, height: number }, r2: { left: number, top: number, width: number, height: number }) { |
