diff options
Diffstat (limited to 'src/client/util/DocumentManager.ts')
| -rw-r--r-- | src/client/util/DocumentManager.ts | 44 | 
1 files changed, 39 insertions, 5 deletions
| diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index ec731da84..a3c7429b9 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -10,6 +10,7 @@ import { DocumentView } from '../views/nodes/DocumentView';  import { LinkManager } from './LinkManager';  import { undoBatch, UndoManager } from './UndoManager';  import { Scripting } from './Scripting'; +import { List } from '../../new_fields/List';  export class DocumentManager { @@ -146,6 +147,7 @@ export class DocumentManager {              if (!contextDoc) {                  let docs = docContext ? await DocListCastAsync(docContext.data) : undefined;                  let found = false; +                // bcz: this just searches within the context for the target -- perhaps it should recursively search through all children?                  docs && docs.map(d => found = found || Doc.AreProtosEqual(d, docDelegate));                  if (docContext && found) {                      let targetContextView: DocumentView | null; @@ -154,16 +156,19 @@ export class DocumentManager {                          docContext.panTransformType = "Ease";                          targetContextView.props.focus(docDelegate, willZoom);                      } else { -                        (dockFunc || CollectionDockingView.Instance.AddRightSplit)(docContext, undefined); +                        (dockFunc || CollectionDockingView.AddRightSplit)(docContext, undefined);                          setTimeout(() => { -                            this.jumpToDocument(docDelegate, willZoom, forceDockFunc, dockFunc, linkPage); -                        }, 10); +                            let dv = DocumentManager.Instance.getDocumentView(docContext); +                            dv && this.jumpToDocument(docDelegate, willZoom, forceDockFunc, +                                doc => dv!.props.focus(dv!.props.Document, true, 1, () => dv!.props.addDocTab(doc, undefined, "inPlace")), +                                linkPage); +                        }, 1050);                      }                  } else {                      const actualDoc = Doc.MakeAlias(docDelegate);                      Doc.BrushDoc(actualDoc);                      if (linkPage !== undefined) actualDoc.curPage = linkPage; -                    (dockFunc || CollectionDockingView.Instance.AddRightSplit)(actualDoc, undefined); +                    (dockFunc || CollectionDockingView.AddRightSplit)(actualDoc, undefined);                  }              } else {                  let contextView: DocumentView | null; @@ -172,7 +177,7 @@ export class DocumentManager {                      contextDoc.panTransformType = "Ease";                      contextView.props.focus(docDelegate, willZoom);                  } else { -                    (dockFunc || CollectionDockingView.Instance.AddRightSplit)(contextDoc, undefined); +                    (dockFunc || CollectionDockingView.AddRightSplit)(contextDoc, undefined);                      setTimeout(() => {                          this.jumpToDocument(docDelegate, willZoom, forceDockFunc, dockFunc, linkPage);                      }, 10); @@ -203,5 +208,34 @@ export class DocumentManager {              return 1;          }      } + +    @action +    animateBetweenPoint = (scrpt: number[], expandedDocs: Doc[] | undefined): void => { +        expandedDocs && expandedDocs.map(expDoc => { +            if (expDoc.isMinimized || expDoc.isAnimating === "min") { // MAXIMIZE DOC +                if (expDoc.isMinimized) {  // docs are never actaully at the minimized location.  so when we unminimize one, we have to set our overrides to make it look like it was at the minimize location +                    expDoc.isMinimized = false; +                    expDoc.animateToPos = new List<number>([...scrpt, 0]); +                    expDoc.animateToDimensions = new List<number>([0, 0]); +                } +                setTimeout(() => { +                    expDoc.isAnimating = "max"; +                    expDoc.animateToPos = new List<number>([0, 0, 1]); +                    expDoc.animateToDimensions = new List<number>([NumCast(expDoc.width), NumCast(expDoc.height)]); +                    setTimeout(() => expDoc.isAnimating === "max" && (expDoc.isAnimating = expDoc.animateToPos = expDoc.animateToDimensions = undefined), 600); +                }, 0); +            } else {  // MINIMIZE DOC +                expDoc.isAnimating = "min"; +                expDoc.animateToPos = new List<number>([...scrpt, 0]); +                expDoc.animateToDimensions = new List<number>([0, 0]); +                setTimeout(() => { +                    if (expDoc.isAnimating === "min") { +                        expDoc.isMinimized = true; +                        expDoc.isAnimating = expDoc.animateToPos = expDoc.animateToDimensions = undefined; +                    } +                }, 600); +            } +        }); +    }  }  Scripting.addGlobal(function focus(doc: any) { DocumentManager.Instance.getDocumentViews(Doc.GetProto(doc)).map(view => view.props.focus(doc, true)); });
\ No newline at end of file | 
