From dc98dae527236651f69a9bbd94e6f68296e417cd Mon Sep 17 00:00:00 2001 From: bobzel Date: Sun, 13 Dec 2020 17:07:12 -0500 Subject: converted TabDocView to just use a ContentFittingDocumentView. Fixed schemView to use a styleProvider --- .../views/nodes/ContentFittingDocumentView.tsx | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/client/views/nodes/ContentFittingDocumentView.tsx') diff --git a/src/client/views/nodes/ContentFittingDocumentView.tsx b/src/client/views/nodes/ContentFittingDocumentView.tsx index f2540dfa7..098e422b8 100644 --- a/src/client/views/nodes/ContentFittingDocumentView.tsx +++ b/src/client/views/nodes/ContentFittingDocumentView.tsx @@ -7,11 +7,9 @@ import { emptyFunction, OmitKeys, returnOne, returnVal } from "../../../Utils"; import { DocumentView, DocumentViewProps } from "../nodes/DocumentView"; import { StyleProp } from "../StyleProvider"; import "./ContentFittingDocumentView.scss"; - interface ContentFittingDocumentViewProps { dontCenter?: "x" | "y" | "xy"; } - @observer export class ContentFittingDocumentView extends React.Component { public get displayName() { return "DocumentView(" + this.props.Document?.title + ")"; } // this makes mobx trace() statements more descriptive @@ -20,23 +18,27 @@ export class ContentFittingDocumentView extends React.Component this.props.PanelHeight()) { - return hscale || 1; + const nativeW = this.nativeWidth; + const nativeH = this.nativeHeight; + let scaling = 1; + if (nativeW && (this.layoutDoc?._fitWidth || this.props.PanelHeight() / nativeH > this.props.PanelWidth() / nativeW)) { + scaling = this.props.PanelWidth() / nativeW; // width-limited or fitWidth + } else if (nativeW && nativeH) { + scaling = this.props.PanelHeight() / nativeH; // height-limited } - return wscale || 1; + return scaling; } @computed get panelWidth() { return this.nativeWidth ? this.nativeWidth * this.nativeScaling : this.props.PanelWidth(); } @computed get panelHeight() { if (this.nativeHeight) { - if (this.props.Document._fitWidth) return Math.min(this.props.PanelHeight(), this.panelWidth / Doc.NativeAspect(this.layoutDoc, this.props.DataDoc, this.props.freezeDimensions) || 1); - return Math.min(this.props.PanelHeight(), this.nativeHeight * this.nativeScaling); + if (this.props.Document._fitWidth) + return Math.min(this.props.PanelHeight(), this.panelWidth / Doc.NativeAspect(this.layoutDoc, this.props.DataDoc, this.props.freezeDimensions) || 1); + else return Math.min(this.props.PanelHeight(), this.nativeHeight * this.nativeScaling); } return this.props.PanelHeight(); } @@ -67,8 +69,7 @@ export class ContentFittingDocumentView extends React.Component