aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DocumentManager.ts
diff options
context:
space:
mode:
authorMonika <monika_hedman@brown.edu>2019-06-26 14:55:55 -0400
committerMonika <monika_hedman@brown.edu>2019-06-26 14:55:55 -0400
commit0df1e6093ee5cc2b9b7510b8f4ea5325fd47ffe8 (patch)
tree4e2f8773abdf219481392b6aef4de1d7f68a6569 /src/client/util/DocumentManager.ts
parent5c17508a78d52fef355f2a71b12d59b027535a0d (diff)
parentdeb85766ac5648cc8e3ab4bf9d182ac5bbbbe144 (diff)
pulled
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r--src/client/util/DocumentManager.ts37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index cd4e90f2d..bc9724b98 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -1,4 +1,4 @@
-import { computed, observable } from 'mobx';
+import { computed, observable, action } from 'mobx';
import { DocumentView } from '../views/nodes/DocumentView';
import { Doc, DocListCast, Opt } from '../../new_fields/Doc';
import { FieldValue, Cast, NumCast, BoolCast } from '../../new_fields/Types';
@@ -139,7 +139,7 @@ export class DocumentManager {
}
@undoBatch
- public jumpToDocument = async (docDelegate: Doc, forceDockFunc: boolean = false, dockFunc?: (doc: Doc) => void, linkPage?: number, docContext?: Doc): Promise<void> => {
+ public jumpToDocument = async (docDelegate: Doc, willZoom: boolean, forceDockFunc: boolean = false, dockFunc?: (doc: Doc) => void, linkPage?: number, docContext?: Doc): Promise<void> => {
let doc = Doc.GetProto(docDelegate);
const contextDoc = await Cast(doc.annotationOn, Doc);
if (contextDoc) {
@@ -153,18 +153,18 @@ export class DocumentManager {
if (!forceDockFunc && (docView = DocumentManager.Instance.getDocumentView(doc))) {
docView.props.Document.libraryBrush = true;
if (linkPage !== undefined) docView.props.Document.curPage = linkPage;
- docView.props.focus(docView.props.Document);
+ docView.props.focus(docView.props.Document, willZoom);
} else {
if (!contextDoc) {
if (docContext) {
let targetContextView: DocumentView | null;
if (!forceDockFunc && docContext && (targetContextView = DocumentManager.Instance.getDocumentView(docContext))) {
docContext.panTransformType = "Ease";
- targetContextView.props.focus(docDelegate);
+ targetContextView.props.focus(docDelegate, willZoom);
} else {
(dockFunc || CollectionDockingView.Instance.AddRightSplit)(docContext);
setTimeout(() => {
- this.jumpToDocument(docDelegate, forceDockFunc, dockFunc, linkPage);
+ this.jumpToDocument(docDelegate, willZoom, forceDockFunc, dockFunc, linkPage);
}, 10);
}
} else {
@@ -178,14 +178,37 @@ export class DocumentManager {
docDelegate.libraryBrush = true;
if (!forceDockFunc && (contextView = DocumentManager.Instance.getDocumentView(contextDoc))) {
contextDoc.panTransformType = "Ease";
- contextView.props.focus(docDelegate);
+ contextView.props.focus(docDelegate, willZoom);
} else {
(dockFunc || CollectionDockingView.Instance.AddRightSplit)(contextDoc);
setTimeout(() => {
- this.jumpToDocument(docDelegate, forceDockFunc, dockFunc, linkPage);
+ this.jumpToDocument(docDelegate, willZoom, forceDockFunc, dockFunc, linkPage);
}, 10);
}
}
}
}
+
+ @action
+ zoomIntoScale = (docDelegate: Doc, scale: number) => {
+ let doc = Doc.GetProto(docDelegate);
+
+ let docView: DocumentView | null;
+ docView = DocumentManager.Instance.getDocumentView(doc);
+ if (docView) {
+ docView.props.zoomToScale(scale);
+ }
+ }
+
+ getScaleOfDocView = (docDelegate: Doc) => {
+ let doc = Doc.GetProto(docDelegate);
+
+ let docView: DocumentView | null;
+ docView = DocumentManager.Instance.getDocumentView(doc);
+ if (docView) {
+ return docView.props.getScale();
+ } else {
+ return 1;
+ }
+ }
} \ No newline at end of file