diff options
| author | bob <bcz@cs.brown.edu> | 2019-07-11 11:00:09 -0400 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2019-07-11 11:00:09 -0400 |
| commit | a9ecaef0c7d870136401dfbb687afdb9dd2843f4 (patch) | |
| tree | e92499439a8c2c3f19defb2fca723b208ce47ca3 /src/client/views/collections/CollectionTreeView.tsx | |
| parent | 35f581ce1beef665265688551f50ca4cd51fd62a (diff) | |
fixed fitToBox stuff.
Diffstat (limited to 'src/client/views/collections/CollectionTreeView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionTreeView.tsx | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index 1280d515c..4685e774d 100644 --- a/src/client/views/collections/CollectionTreeView.tsx +++ b/src/client/views/collections/CollectionTreeView.tsx @@ -315,10 +315,10 @@ class TreeView extends React.Component<TreeViewProps> { return ele; } - @computed get docBounds() { + @computed get boundsOfCollectionDocument() { if (StrCast(this.props.document.type).indexOf(DocTypes.COL) === -1) return undefined; let layoutDoc = Doc.expandTemplateLayout(this.props.document, this.props.dataDoc); - return Doc.ComputeContentBounds(layoutDoc); + return Doc.ComputeContentBounds(DocListCast(layoutDoc.data)); } docWidth = () => { let aspect = NumCast(this.props.document.nativeHeight) / NumCast(this.props.document.nativeWidth); @@ -326,7 +326,7 @@ class TreeView extends React.Component<TreeViewProps> { return NumCast(this.props.document.nativeWidth) ? Math.min(this.props.document[WidthSym](), this.props.panelWidth() - 5) : this.props.panelWidth() - 5; } docHeight = () => { - let bounds = this.docBounds; + let bounds = this.boundsOfCollectionDocument; return Math.min(this.MAX_EMBED_HEIGHT, (() => { let aspect = NumCast(this.props.document.nativeHeight) / NumCast(this.props.document.nativeWidth); if (aspect) return this.docWidth() * aspect; @@ -334,10 +334,6 @@ class TreeView extends React.Component<TreeViewProps> { return NumCast(this.props.document.height) ? NumCast(this.props.document.height) : 50; })()); } - fitToBox = () => { - let bounds = this.docBounds!; - return [(bounds.x + bounds.r) / 2, (bounds.y + bounds.b) / 2, Math.min(this.docHeight() / (bounds.b - bounds.y), this.docWidth() / (bounds.r - bounds.x))]; - } render() { let contentElement: (JSX.Element | null) = null; @@ -360,7 +356,7 @@ class TreeView extends React.Component<TreeViewProps> { Document={layoutDoc} DataDocument={this.resolvedDataDoc} renderDepth={this.props.renderDepth} - fitToBox={this.docBounds && !NumCast(this.props.document.nativeWidth) ? this.fitToBox : undefined} + fitToBox={this.boundsOfCollectionDocument !== undefined} width={this.docWidth} height={this.docHeight} getTransform={this.docTransform} |
