diff options
| author | bob <bcz@cs.brown.edu> | 2020-02-03 13:01:49 -0500 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2020-02-03 13:01:49 -0500 |
| commit | 6b80df7d997fbde95b5571f790d9c0ed8e1950c4 (patch) | |
| tree | 9015f3bb6e98adc60538b0e5400765297d696b41 /src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx | |
| parent | 646de60fc314198b97172c62f414ffb9576ffb98 (diff) | |
attempt at performance tuning.
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx')
| -rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx index da0b51196..bcd81e17a 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx @@ -241,17 +241,15 @@ function normalizeResults(panelDim: number[], fontHeight: number, childPairs: { poolData: ObservableMap<string, PoolData>, viewDefsToJSX: (views: any) => ViewDefResult[], groupNames: PivotData[], minWidth: number, extras: PivotData[]) { const grpEles = groupNames.map(gn => ({ x: gn.x, y: gn.y, height: gn.height }) as PivotData); - const docEles = childPairs.filter(d => !d.layout.isMinimized).map(pair => - docMap.get(pair.layout) || { x: NumCast(pair.layout.x), y: NumCast(pair.layout.y), width: pair.layout[WidthSym](), height: pair.layout[HeightSym]() } as PivotData // new pos is computed pos, or pos written to the document's fields - ); + const docEles = childPairs.filter(d => !d.layout.isMinimized).map(pair => docMap.get(pair.layout) as PivotData); const aggBounds = aggregateBounds(docEles.concat(grpEles), 0, 0); aggBounds.r = Math.max(minWidth, aggBounds.r - aggBounds.x); const wscale = panelDim[0] / (aggBounds.r - aggBounds.x); let scale = wscale * (aggBounds.b - aggBounds.y) > panelDim[1] ? (panelDim[1]) / (aggBounds.b - aggBounds.y) : wscale; if (Number.isNaN(scale)) scale = 1; - childPairs.map(pair => { - const fallbackPos = { + childPairs.filter(d => !d.layout.isMinimized).map(pair => { + const newPosRaw = docMap.get(pair.layout) || {// new pos is computed pos, or pos written to the document's fields x: NumCast(pair.layout.x), y: NumCast(pair.layout.y), z: NumCast(pair.layout.z), @@ -260,10 +258,14 @@ function normalizeResults(panelDim: number[], fontHeight: number, childPairs: { width: NumCast(pair.layout._width), height: NumCast(pair.layout._height) }; - const newPosRaw = docMap.get(pair.layout) || fallbackPos; // new pos is computed pos, or pos written to the document's fields const newPos = { - x: newPosRaw.x * scale, y: newPosRaw.y * scale, z: newPosRaw.z, zIndex: newPosRaw.zIndex, highlight: newPosRaw.highlight, - width: (newPosRaw.width || 0) * scale, height: newPosRaw.height! * scale + x: newPosRaw.x * scale, + y: newPosRaw.y * scale, + z: newPosRaw.z, + highlight: newPosRaw.highlight, + zIndex: newPosRaw.zIndex, + width: (newPosRaw.width || 0) * scale, + height: newPosRaw.height! * scale }; const lastPos = poolData.get(pair.layout[Id]); // last computed pos if (!lastPos || newPos.x !== lastPos.x || newPos.y !== lastPos.y || newPos.z !== lastPos.z || newPos.zIndex !== lastPos.zIndex || newPos.width !== lastPos.width || newPos.height !== lastPos.height) { @@ -279,8 +281,7 @@ function normalizeResults(panelDim: number[], fontHeight: number, childPairs: { y: gname.y * scale, color: gname.color, width: gname.width === undefined ? undefined : gname.width * scale, - height: Math.max(fontHeight, gname.height! * scale), - // height: gname.height === undefined ? undefined : gname.height * scale, + height: Math.max(fontHeight, (gname.height || 0) * scale), fontSize: gname.fontSize })))) }; |
