aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMonika Hedman <monika_hedman@brown.edu>2019-02-24 16:09:38 -0500
committerMonika Hedman <monika_hedman@brown.edu>2019-02-24 16:09:38 -0500
commit2d604d7db4b4533e0e1deb30e624d81559c2dd07 (patch)
tree00b4b651c576dbe2654a723a4b01966ae916998f /src
parent0d593c4425627bae622122102a0e558a7b1b9ec4 (diff)
it works!
Diffstat (limited to 'src')
-rw-r--r--src/client/views/DocumentManager.tsx24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/client/views/DocumentManager.tsx b/src/client/views/DocumentManager.tsx
index 194c47cf2..ab54a7955 100644
--- a/src/client/views/DocumentManager.tsx
+++ b/src/client/views/DocumentManager.tsx
@@ -79,7 +79,7 @@ export class DocumentManager {
let docView: DocumentView | null;
if (doc instanceof Document) {
- docView = this.getDocumentViewFreeform(doc)
+ docView = DocumentManager.Instance.getDocumentViewFreeform(doc)
}
else {
docView = doc
@@ -99,16 +99,22 @@ export class DocumentManager {
//base case: parent of parent does not exist
if (docView.props.ContainingCollectionView == null) {
scale = docView.props.ScreenToLocalTransform().Scale
- XView = (-docView.props.ScreenToLocalTransform().TranslateX * scale) + (window.innerWidth / 2) - (width * scale / 2)
- YView = (-docView.props.ScreenToLocalTransform().TranslateY * scale) + (window.innerHeight / 2) - (height * scale / 2)
+
+ let doc = docView.props.Document;
+
+ XView = (-doc.GetNumber(KeyStore.X, 0) * scale) + (window.innerWidth / 2) - (width * scale / 2)
+ YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) + (window.innerHeight / 2) - (height * scale / 2)
//set x and y view of parent
+ if (docView instanceof CollectionFreeFormView) {
+ DocumentManager.Instance.setViewportXY(docView, XView, YView)
+ }
}
//parent is not main, parent is centered and calls itself
else {
if (docView.props.ContainingCollectionView.props.ContainingDocumentView && docView.props.ContainingCollectionView.props.ContainingDocumentView.MainContent.current) {
//view of parent
let tempCollectionView = docView.props.ContainingCollectionView.props.ContainingDocumentView
-
+ let doc = docView.props.Document
let parentWidth = docView.props.ContainingCollectionView.props.ContainingDocumentView.MainContent.current.clientWidth
let parentHeight = docView.props.ContainingCollectionView.props.ContainingDocumentView.MainContent.current.clientHeight
@@ -117,9 +123,9 @@ export class DocumentManager {
//scale of parent
scale = tempCollectionView.props.ScreenToLocalTransform().Scale
- XView = (-docView.props.ScreenToLocalTransform().TranslateX * scale) + (parentWidth / 2) - (width * scale / 2);
- YView = (-docView.props.ScreenToLocalTransform().TranslateY * scale) + (parentHeight / 2) - (height * scale / 2);
- //node.Parent.setViewportXY(XView, YView);
+ XView = (-doc.GetNumber(KeyStore.X, 0) * scale) + (parentWidth / 2) - (width * scale / 2);
+ YView = (-doc.GetNumber(KeyStore.Y, 0) * scale) + (parentHeight / 2) - (height * scale / 2);
+ // //node.Parent.setViewportXY(XView, YView);
DocumentManager.Instance.setViewportXY(docView.props.ContainingCollectionView, XView, YView)
return DocumentManager.Instance.centerNode(docView.props.ContainingCollectionView.props.DocumentForCollection);
@@ -139,6 +145,8 @@ export class DocumentManager {
@action
private setViewportXY(collection: CollectionFreeFormView, x: number, y: number) {
console.log("viewport is setting")
- collection.props.ScreenToLocalTransform().center(x, y)
+ let doc = collection.props.DocumentForCollection;
+ doc.SetNumber(KeyStore.PanX, x);
+ doc.SetNumber(KeyStore.PanY, y);
}
} \ No newline at end of file