aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionDockingView.tsx
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-02-12 16:38:13 -0500
committerTyler Schicke <tyler_schicke@brown.edu>2019-02-12 16:38:13 -0500
commit46a4c26dbadefaf981637f79fb5f76e458baac9d (patch)
tree71ba5836cfbef42fc4e17b699c2bb95ef2e86274 /src/client/views/collections/CollectionDockingView.tsx
parent6ef7d8f10b2ec78491b66ea4e2f6cebce3b0230a (diff)
parent7a93f60c9529e5d175e617fc7c07145a9b33e572 (diff)
Merge branch 'master' of github-tsch-brown:browngraphicslab/Dash-Web into transforms
Diffstat (limited to 'src/client/views/collections/CollectionDockingView.tsx')
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx63
1 files changed, 44 insertions, 19 deletions
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index e3d50eb80..d3e90d11c 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -2,7 +2,7 @@ import FlexLayout from "flexlayout-react";
import * as GoldenLayout from "golden-layout";
import 'golden-layout/src/css/goldenlayout-base.css';
import 'golden-layout/src/css/goldenlayout-dark-theme.css';
-import { action, computed } from "mobx";
+import { action, computed, reaction, observable } from "mobx";
import { observer } from "mobx-react";
import * as ReactDOM from 'react-dom';
import { Document } from "../../../fields/Document";
@@ -44,7 +44,7 @@ export class CollectionDockingView extends CollectionViewBase {
const { CollectionFieldKey: fieldKey, DocumentForCollection: Document } = this.props;
const value: Document[] = Document.GetData(fieldKey, ListField, []);
var docs = value.map(doc => {
- return { type: 'component', componentName: 'documentViewComponent', componentState: { doc: doc } };
+ return { type: 'component', componentName: 'documentViewComponent', componentState: { doc: doc, scaling: 1 } };
});
return new GoldenLayout({
settings: {
@@ -111,6 +111,7 @@ export class CollectionDockingView extends CollectionViewBase {
public static myLayout: any = null;
+ public rcs: Array<RenderClass> = new Array();
private static _dragDiv: any = null;
private static _dragParent: HTMLElement | null = null;
private static _dragElement: HTMLDivElement;
@@ -119,7 +120,7 @@ export class CollectionDockingView extends CollectionViewBase {
var newItemConfig = {
type: 'component',
componentName: 'documentViewComponent',
- componentState: { doc: dragDoc }
+ componentState: { doc: dragDoc, scaling: 1 }
};
this._dragElement = dragElement;
this._dragParent = dragElement.parentElement;
@@ -160,7 +161,6 @@ export class CollectionDockingView extends CollectionViewBase {
CollectionDockingView.myLayout._maximizedStack = null;
}
}
-
//
// Creates a vertical split on the right side of the docking view, and then adds the Document to that split
//
@@ -241,21 +241,8 @@ export class CollectionDockingView extends CollectionViewBase {
var containingDiv = "component_" + me.nextId();
container.getElement().html("<div id='" + containingDiv + "'></div>");
setTimeout(function () {
- var htmlElement = document.getElementById(containingDiv);
- container.on('resize', (e: any) => {
- // state.doc.SetNumber(KeyStore.Width, htmlElement!.clientWidth);
- // if (htmlElement!.clientHeight > 0)
- // state.doc.SetNumber(KeyStore.Height, htmlElement!.clientHeight);
- })
- ReactDOM.render((
- <DocumentView key={state.doc.Id} Document={state.doc}
- AddDocument={me.addDocument} RemoveDocument={me.removeDocument}
- GetTransform={() => Transform.Identity}
- Scaling={1}
- ContainingCollectionView={me} DocumentView={undefined} />
- ),
- htmlElement
- );
+ state.rc = new RenderClass(containingDiv, state.doc, me, container);
+ me.rcs.push(state.rc);
if (CollectionDockingView.myLayout._maxstack != null) {
CollectionDockingView.myLayout._maxstack.click();
}
@@ -294,4 +281,42 @@ export class CollectionDockingView extends CollectionViewBase {
</div>
);
}
+}
+
+class RenderClass {
+
+ @observable _resizeCount: number = 0;
+
+ _collectionDockingView: CollectionDockingView;
+ _htmlElement: any;
+ _document: Document;
+ constructor(containingDiv: string, doc: Document, me: CollectionDockingView, container: any) {
+ this._collectionDockingView = me;
+ this._htmlElement = document.getElementById(containingDiv);
+ this._document = doc;
+ container.on('resize', action((e: any) => {
+ var nativeWidth = doc.GetNumber(KeyStore.NativeWidth, 0);
+ if (this._htmlElement != null && this._htmlElement.childElementCount > 0 && nativeWidth > 0) {
+ let scaling = nativeWidth > 0 ? this._htmlElement!.clientWidth / nativeWidth : 1;
+ (this._htmlElement!.children[0] as any).style.transformOrigin = "0px 0px";
+ (this._htmlElement!.children[0] as any).style.transform = `translate(0px,0px) scale(${scaling}, ${scaling}) `;
+ (this._htmlElement!.children[0] as any).style.width = nativeWidth.toString() + "px";
+ }
+ }));
+
+ this.render();
+ }
+ render() {
+ var nativeWidth = this._document.GetNumber(KeyStore.NativeWidth, 0);
+ let scaling = nativeWidth > 0 ? this._htmlElement!.clientWidth / nativeWidth : 1;
+ ReactDOM.render((
+ <DocumentView key={this._document.Id} Document={this._document}
+ AddDocument={this._collectionDockingView.addDocument} RemoveDocument={this._collectionDockingView.removeDocument}
+ GetTransform={() => Transform.Identity}
+ Scaling={scaling}
+ ContainingCollectionView={this._collectionDockingView} DocumentView={undefined} />
+ ),
+ this._htmlElement
+ );
+ }
} \ No newline at end of file