aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-02-11 02:38:23 -0500
committerbobzel <zzzman@gmail.com>2021-02-11 02:38:23 -0500
commit42865450ea252e340d89a1f67c8a2dc0b9c6eae3 (patch)
tree57b6179b2b4b43702602a0a8571ec90353898c02 /src
parentc86cb3966ecb905c2dc6a6236b71d7ce9c8fb80f (diff)
more tweaking to simplify link following mechanisms.
Diffstat (limited to 'src')
-rw-r--r--src/client/util/DocumentManager.ts13
-rw-r--r--src/client/util/LinkManager.ts6
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx29
3 files changed, 20 insertions, 28 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index e5ef924d6..5d3f8af57 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -172,18 +172,7 @@ export class DocumentManager {
first.focus(targetDoc, false);
}
} else if (docView && (targetDocContextView || !targetDocContext)) { // we have a docView already and aren't forced to create a new one ... just focus on the document. TODO move into view if necessary otherwise just highlight?
- const first = annotatedDoc && getFirstDocView(annotatedDoc);
- const targetFocus = (outFocus?: boolean) => docView.props.focus(docView.rootDoc, willZoom, undefined, (didFocus: boolean) => focusAndFinish(outFocus || didFocus));
- const annoFocus = (outFocus?: boolean) => first?.props.focus(first.rootDoc, false, undefined, (didFocus: boolean) => {
- targetFocus(outFocus || didFocus);
- return false;
- });
- const contextFocus = targetDocContext === annotatedDoc ? undefined : (outFocus?: boolean) => targetDocContextView?.props.focus(targetDocContext, false, undefined, (didFocus: boolean) => {
- annoFocus(outFocus || didFocus);
- return false;
- });
- (contextFocus || annoFocus || targetFocus)();
- highlight();
+ docView.props.focus(docView.rootDoc, willZoom, undefined, (didFocus: boolean) => focusAndFinish(didFocus));
} else {
if (!targetDocContext) { // we don't have a view and there's no context specified ... create a new view of the target using the dockFunc or default
createViewFunc(Doc.BrushDoc(targetDoc), finished); // bcz: should we use this?: Doc.MakeAlias(targetDoc)));
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index 9034484d3..8a6ed9944 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -104,10 +104,10 @@ export class LinkManager {
const batch = UndoManager.StartBatch("follow link click");
// open up target if it's not already in view ...
const createViewFunc = (doc: Doc, followLoc: string, finished: Opt<() => void>) => {
- const targetFocusAfterDocFocus = () => {
+ const targetFocusAfterDocFocus = (didFocus: boolean) => {
const where = StrCast(sourceDoc.followLinkLocation) || followLoc;
const hackToCallFinishAfterFocus = () => {
- finished && setTimeout(finished, 0); // finished() needs to be called right after hackToCallFinishAfterFocus(), but there's no callback for that so we use the hacky timeout.
+ finished && setTimeout(finished); // finished() needs to be called right after hackToCallFinishAfterFocus(), but there's no callback for that so we use the hacky timeout.
return false; // we must return false here so that the zoom to the document is not reversed. If it weren't for needing to call finished(), we wouldn't need this function at all since not having it is equivalent to returning false
};
const addTab = docViewProps.addDocTab(doc, where);
@@ -118,7 +118,7 @@ export class LinkManager {
return where !== "inPlace" || addTab; // return true to reset the initial focus&zoom (return false for 'inPlace' since resetting the initial focus&zoom will negate the zoom into the target)
};
if (!sourceDoc.followLinkZoom) {
- targetFocusAfterDocFocus();
+ targetFocusAfterDocFocus(false);
} else {
// first focus & zoom onto this (the clicked document). Then execute the function to focus on the target
docViewProps.focus(sourceDoc, BoolCast(sourceDoc.followLinkZoom, true), 1, targetFocusAfterDocFocus);
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 6fdd569da..7ae4137d9 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -913,27 +913,30 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P
newState.initializers![this.Document[Id]] = { panX: px, panY: py };
HistoryUtil.pushState(newState);
}
-
- if (DocListCast(this.dataDoc[this.props.fieldKey]).includes(doc)) {
- // glr: freeform transform speed can be set by adjusting presTransition field - needs a way of knowing when presentation is not active...
- if (!doc.z) this.setPan(px, py, doc.focusSpeed || doc.focusSpeed === 0 ? `transform ${doc.focusSpeed}ms` : "transform 500ms", true); // docs that are floating in their collection can't be panned to from their collection -- need to propagate the pan to a parent freeform somehow
- }
- Doc.BrushDoc(this.props.Document);
-
+ // focus on the document in the collection
+ const didMove = !doc.z && (px !== savedState.px || py !== savedState.py);
+ const focusSpeed = didMove ? (doc.focusSpeed !== undefined ? Number(doc.focusSpeed) : 500) : 0;
+ // glr: freeform transform speed can be set by adjusting presTransition field - needs a way of knowing when presentation is not active...
+ if (didMove) this.setPan(px, py, `transform ${focusSpeed}ms`, true); // docs that are floating in their collection can't be panned to from their collection -- need to propagate the pan to a parent freeform somehow
+ Doc.BrushDoc(this.rootDoc);
!doc.hidden && Doc.linkFollowHighlight(doc);
- this.props.focus(this.props.Document, undefined, undefined, (didFocus: boolean) => {
+
+ // focus the collection in its parent view. the parent view after focusing determines whether to reset the view change within the collection
+ this.props.focus(this.rootDoc, willZoom, scale, (didFocus: boolean) => {
setTimeout(() => {
- if (afterFocus?.(didFocus || (px !== savedState.px || py !== savedState.py))) {
+ if (afterFocus?.(didFocus || didMove)) {
+ doc.hidden && Doc.UnHighlightDoc(doc);
this.Document._panX = savedState.px;
this.Document._panY = savedState.py;
this.Document[this.scaleFieldKey] = savedState.s;
this.Document._viewTransition = savedState.pt;
+ } else {
+ doc.hidden && Doc.UnHighlightDoc(doc);
}
- doc.hidden && Doc.UnHighlightDoc(doc);
- }, px !== savedState.px || py !== savedState.py ? 500 : 0);
+ }, focusSpeed);
return false;
- });
- }
+ })
+ };
}
setPanIntoView = (doc: Doc) => {