diff options
| author | bobzel <zzzman@gmail.com> | 2024-04-29 23:00:52 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-04-29 23:00:52 -0400 |
| commit | 8d68db4de347e772a5272fd0519fa30c03a30db4 (patch) | |
| tree | d87386b529fa9ed1bf2c37debcdca334fe155b42 /src/client/views/collections/collectionFreeForm | |
| parent | f6a741f38a33bdb30b3a1d88215656dcd3d0712d (diff) | |
updating showDocument to not have to know about groups -- all group logic is in collectionfreeformview.
Diffstat (limited to 'src/client/views/collections/collectionFreeForm')
| -rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 30 |
1 files changed, 18 insertions, 12 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(); |
