diff options
author | bob <bcz@cs.brown.edu> | 2019-02-13 17:02:23 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-02-13 17:02:23 -0500 |
commit | 3f98d6ec6050e7faa15179871f0d9669c1188a78 (patch) | |
tree | b7190408a4b76dbdd1821e7ea2324a33dc219515 /src/client/views/collections/CollectionDockingView.tsx | |
parent | c1b556748df727e9c4d92db74adddf51adea637e (diff) |
cool, something worked. panes resize properly now.
Diffstat (limited to 'src/client/views/collections/CollectionDockingView.tsx')
-rw-r--r-- | src/client/views/collections/CollectionDockingView.tsx | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index 725b68a54..1653994cf 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -7,7 +7,6 @@ import { observer } from "mobx-react"; import { Document } from "../../../fields/Document"; import { KeyStore } from "../../../fields/Key"; import { ListField } from "../../../fields/ListField"; -import { NumberField } from "../../../fields/NumberField"; import { DragManager } from "../../util/DragManager"; import { Transform } from "../../util/Transform"; import { DocumentView } from "../nodes/DocumentView"; @@ -15,6 +14,7 @@ import "./CollectionDockingView.scss"; import { CollectionViewBase, CollectionViewProps, COLLECTION_BORDER_WIDTH } from "./CollectionViewBase"; import React = require("react"); import * as ReactDOM from 'react-dom'; +import Measure from "react-measure"; @observer export class CollectionDockingView extends CollectionViewBase { @@ -66,7 +66,6 @@ export class CollectionDockingView extends CollectionViewBase { } private nextId = (function () { var _next_id = 0; return function () { return _next_id++; } })(); - @action onResize = (event: any) => { var cur = this.props.ContainingDocumentView!.MainContent.current; @@ -297,22 +296,27 @@ interface DockingProps { } @observer export class RenderClass extends React.Component<DockingProps> { - @observable _forceRerender = 0; - constructor(props: DockingProps) { - super(props); - this.props.Container.on('resize', action((e: any) => this._forceRerender++)); - } + @observable + private _parentScaling = 1; // used to transfer the dimensions of the content pane in the DOM to the ParentScaling prop of the DocumentView + render() { - let x = this._forceRerender; let nativeWidth = this.props.Document.GetNumber(KeyStore.NativeWidth, 0); - let parentScaling = nativeWidth > 0 ? this.props.HtmlElement!.clientWidth / nativeWidth : 1; - return <div> + var layout = this.props.Document.GetText(KeyStore.Layout, ""); + var content = <DocumentView key={this.props.Document.Id} Document={this.props.Document} AddDocument={this.props.CollectionDockingView.addDocument} RemoveDocument={this.props.CollectionDockingView.removeDocument} GetTransform={() => Transform.Identity} - ParentScaling={parentScaling} + ParentScaling={this._parentScaling} ContainingCollectionView={this.props.CollectionDockingView} DocumentView={undefined} /> - </div> + + if (nativeWidth > 0 && (layout.indexOf("CollectionFreeForm") == -1 || layout.indexOf("AnnotationsKey") != -1)) { + return <Measure onResize={ + action((r: any) => this._parentScaling = nativeWidth > 0 ? r.entry.width / nativeWidth : 1)} + > + {({ measureRef }) => <div ref={measureRef}> {content} </div>} + </Measure> + } + return <div> {content} </div> } }
\ No newline at end of file |