diff options
Diffstat (limited to 'src/client/views')
| -rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 30 | ||||
| -rw-r--r-- | src/client/views/nodes/FieldView.tsx | 3 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 8a859a3fd..986c1e357 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -310,7 +310,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection } focusOnPoint = (options: FocusViewOptions) => { - const {pointFocus, zoomTime, didMove} = options; + const { pointFocus, zoomTime, didMove } = options; if (!this.Document.isGroup && pointFocus && !didMove) { const dfltScale = this.isAnnotationOverlay ? 1 : 0.5; if (this.layoutDoc[this.scaleFieldKey] !== dfltScale) { @@ -322,6 +322,14 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection return undefined; }; + /** + * Focusing on a member of a group - + * Since groups can't pan and zoom like regular collections, this method focuses on a Doc in a group by + * focusing on the group with an additional transformation to force the final focus to be on the center of the group item. + * @param anchor + * @param options + * @returns + */ groupFocus = (anchor: Doc, options: FocusViewOptions) => { if (options.pointFocus) return this.focusOnPoint(options); options.docTransform = new Transform(NumCast(anchor.x) + NumCast(anchor._width)/2 - NumCast(this.layoutDoc[this.panXFieldKey]), @@ -331,19 +339,17 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection return res; }; - focus = (anchor: Doc, options: FocusViewOptions) => { + focus = (anchor: Doc, options: FocusViewOptions): any => { + if (anchor.isGroup && !options.docTransform && options.contextPath?.length) { + // don't focus on group if there's a context path because we're about to focus on a group item + // which will override any group focus. (If we allowed the group to focus, it would mark didMove even if there were no net movement) + return undefined; + } if (this._lightboxDoc) return undefined; if (options.pointFocus) return this.focusOnPoint(options); - if (anchor === this.Document) { - // if (options.willZoomCentered && options.zoomScale) { - // this.fitContentOnce(); - // options.didMove = true; - // } - } - // prettier-ignore - if (anchor.type !== DocumentType.CONFIG && - !DocListCast(this.Document[this.fieldKey ?? Doc.LayoutFieldKey(this.Document)]).includes(anchor) && // - !this.childLayoutPairs.map(pair => pair.layout).includes(anchor)) { + const anchorInCollection = DocListCast(this.Document[this.fieldKey ?? Doc.LayoutFieldKey(this.Document)]).includes(anchor); + const anchorInChildViews = this.childLayoutPairs.map(pair => pair.layout).includes(anchor); + if (anchor.type !== DocumentType.CONFIG && !anchorInCollection && !anchorInChildViews) { return undefined; } const xfToCollection = options?.docTransform ?? Transform.Identity(); diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index 52dc632ae..ab0850790 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -30,7 +30,8 @@ export interface FocusViewOptions { zoomTextSelections?: boolean; // whether to display a zoomed overlay of anchor text selections toggleTarget?: boolean; // whether to toggle target on and off easeFunc?: 'linear' | 'ease'; // transition method for scrolling - pointFocus?: {X:number, Y: number }; // clientX and clientY coordinates to focus on instead of a document target (used by explore mode) + pointFocus?: { X: number; Y: number }; // clientX and clientY coordinates to focus on instead of a document target (used by explore mode) + contextPath?: Doc[]; // path of inner documents that will also be focused } export type FocusFuncType = (doc: Doc, options: FocusViewOptions) => Opt<number>; // eslint-disable-next-line no-use-before-define |
