diff options
| author | geireann <geireann.lindfield@gmail.com> | 2024-04-28 16:01:49 -0400 |
|---|---|---|
| committer | geireann <geireann.lindfield@gmail.com> | 2024-04-28 16:01:49 -0400 |
| commit | ab873e90112f2cac204a57a1b405cc241f7e8381 (patch) | |
| tree | 763a93ed2d584916d08e12770d39c6ddb377c5f0 /src/client/views/collections/collectionFreeForm | |
| parent | 729114c0867e3cc8d8e0668bae451976b387cb34 (diff) | |
cleaned up explore mode to use focus(). fixed focusing on group doc elements to not focus on group first.
Diffstat (limited to 'src/client/views/collections/collectionFreeForm')
| -rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 31 |
1 files changed, 17 insertions, 14 deletions
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 |
