aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/DocumentDecorations.tsx19
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx12
2 files changed, 15 insertions, 16 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 48f5f01a1..7985b77dd 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -111,17 +111,6 @@ export class DocumentDecorations extends React.Component {
SelectionManager.SelectedDocuments().forEach(element => {
const rect = element.screenRect;
- // if (rect.width !== 0) {
- // let scale = element.width / rect.width;
- // let actualdW = Math.max(element.width + (dW * scale), 20);
- // let actualdH = Math.max(element.height + (dH * scale), 20);
- // element.x += dX * (actualdW - element.width);
- // element.y += dY * (actualdH - element.height);
- // if (Math.abs(dW) > Math.abs(dH))
- // element.width = actualdW;
- // else
- // element.height = actualdH;
- // }
if (rect.width !== 0) {
let doc = element.props.Document;
let width = doc.GetOrCreate(KeyStore.Width, NumberField);
@@ -133,6 +122,14 @@ export class DocumentDecorations extends React.Component {
let actualdH = Math.max(height.Data + (dH * scale), 20);
x.Data += dX * (actualdW - width.Data);
y.Data += dY * (actualdH - height.Data);
+ var nativeWidth = doc.GetNumber(KeyStore.NativeWidth, 0);
+ var nativeHeight = doc.GetNumber(KeyStore.NativeHeight, 0);
+ if (nativeWidth > 0 && nativeHeight > 0) {
+ if (Math.abs(dW) > Math.abs(dH))
+ actualdH = nativeHeight / nativeWidth * actualdW;
+ else
+ actualdW = nativeWidth / nativeHeight * actualdH;
+ }
width.Data = actualdW;
height.Data = actualdH;
}
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 9c396e412..842312faa 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -98,7 +98,6 @@ export class CollectionDockingView extends CollectionViewBase {
if (this._goldenLayout.root.contentItems[0].isRow) {
this._goldenLayout.root.contentItems[0].addChild(newContentItem);
- collayout.callDownwards('setSize');
}
else {
var collayout = this._goldenLayout.root.contentItems[0];
@@ -110,7 +109,6 @@ export class CollectionDockingView extends CollectionViewBase {
collayout.config["width"] = 50;
newContentItem.config["width"] = 50;
- collayout.parent.callDownwards('setSize');
}
this._forceRecreate = true;
}
@@ -227,12 +225,16 @@ interface DockedFrameProps {
@observer
export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
- private _mainCont = React.createRef<HTMLDivElement>();
+ _mainCont: any = null;
constructor(props: any) {
super(props);
Server.GetField(this.props.documentId, (f) => { this.Document = f as Document; })
}
+ setMainCont: any = (element: any) => {
+ this._mainCont = element;
+ }
+
@observable
private _parentScaling = 1; // used to transfer the dimensions of the content pane in the DOM to the ParentScaling prop of the DocumentView
@@ -245,13 +247,13 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
let nativeWidth = this.Document.GetNumber(KeyStore.NativeWidth, 0);
var layout = this.Document.GetText(KeyStore.Layout, "");
var content =
- <div ref={this._mainCont}>
+ <div ref={this.setMainCont}>
<DocumentView key={this.Document.Id} Document={this.Document}
AddDocument={undefined}
RemoveDocument={undefined}
Scaling={this._parentScaling}
ScreenToLocalTransform={() => {
- let { scale, translateX, translateY } = Utils.GetScreenTransform(this._mainCont.current!);
+ let { scale, translateX, translateY } = Utils.GetScreenTransform(this._mainCont);
var props = CollectionDockingView.Instance.props;
return props.ScreenToLocalTransform().translate(-translateX, -translateY).scale(scale / this._parentScaling)
}}