From ab873e90112f2cac204a57a1b405cc241f7e8381 Mon Sep 17 00:00:00 2001
From: geireann <geireann.lindfield@gmail.com>
Date: Sun, 28 Apr 2024 16:01:49 -0400
Subject: cleaned up explore mode to use focus().  fixed focusing on group doc
 elements to not focus on group first.

---
 .../collectionFreeForm/CollectionFreeFormView.tsx  | 31 ++++++++++++----------
 1 file changed, 17 insertions(+), 14 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index d3998aee8..8a859a3fd 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -309,8 +309,23 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
         return dispTime === -1 || curTime === -1 || (curTime - dispTime >= -1e-4 && curTime <= endTime);
     }
 
+    focusOnPoint = (options: FocusViewOptions) => {
+        const {pointFocus, zoomTime, didMove} = options;
+        if (!this.Document.isGroup && pointFocus && !didMove) {
+            const dfltScale = this.isAnnotationOverlay ? 1 : 0.5;
+            if (this.layoutDoc[this.scaleFieldKey] !== dfltScale) {
+                this.zoomSmoothlyAboutPt(this.screenToFreeformContentsXf.transformPoint(pointFocus.X, pointFocus.Y), dfltScale, zoomTime);
+                options.didMove = true;
+                return zoomTime;
+            }
+        }
+        return undefined;
+    };
+
     groupFocus = (anchor: Doc, options: FocusViewOptions) => {
-        options.docTransform = new Transform(-NumCast(this.layoutDoc[this.panXFieldKey]) + NumCast(anchor.x), -NumCast(this.layoutDoc[this.panYFieldKey]) + NumCast(anchor.y), 1);
+        if (options.pointFocus) return this.focusOnPoint(options);
+        options.docTransform = new Transform(NumCast(anchor.x) + NumCast(anchor._width)/2 - NumCast(this.layoutDoc[this.panXFieldKey]),
+                                             NumCast(anchor.y) + NumCast(anchor._height)/2- NumCast(this.layoutDoc[this.panYFieldKey]), 1); // prettier-ignore
         const res = this._props.focus(this.Document, options);
         options.docTransform = undefined;
         return res;
@@ -318,6 +333,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
 
     focus = (anchor: Doc, options: FocusViewOptions) => {
         if (this._lightboxDoc) return undefined;
+        if (options.pointFocus) return this.focusOnPoint(options);
         if (anchor === this.Document) {
             // if (options.willZoomCentered && options.zoomScale) {
             //     this.fitContentOnce();
@@ -1980,19 +1996,6 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
             </div>
         );
     }
-    browseTo = (clientX: number, clientY: number, browseTransitionTime: number): boolean => {
-        if (!this.Document.isGroup) {
-            const dfltScale = this.isAnnotationOverlay ? 1 : 0.5;
-            if (this.layoutDoc[this.scaleFieldKey] !== dfltScale) {
-                this.zoomSmoothlyAboutPt(this.screenToFreeformContentsXf.transformPoint(clientX, clientY), dfltScale, browseTransitionTime);
-                return true;
-            }
-            return !!this.DocumentView?.()
-                .containerViewPath?.()
-                ?.some(cont => cont.ComponentView?.browseTo?.(clientX, clientY, browseTransitionTime));
-        }
-        return false;
-    };
 }
 
 @observer
-- 
cgit v1.2.3-70-g09d2

