From 729114c0867e3cc8d8e0668bae451976b387cb34 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sun, 28 Apr 2024 13:08:09 -0400 Subject: simplified explore mode implementation --- .../collectionFreeForm/CollectionFreeFormView.tsx | 44 +++++++--------------- 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'src/client/views/collections/collectionFreeForm') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index fa4dbf9a2..d3998aee8 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -241,7 +241,6 @@ export class CollectionFreeFormView extends CollectionSubView this._keyframeEditing; - onBrowseClickHandler = () => this._props.onBrowseClickScript?.() || ScriptCast(this.layoutDoc.onBrowseClick); onChildClickHandler = () => this._props.childClickScript || ScriptCast(this.Document.onChildClick); onChildDoubleClickHandler = () => this._props.childDoubleClickScript || ScriptCast(this.Document.onChildDoubleClick); elementFunc = () => this._layoutElements; @@ -726,11 +725,7 @@ export class CollectionFreeFormView extends CollectionSubView { if (this._lightboxDoc) this._lightboxDoc = undefined; if (ClientUtils.isClick(e.pageX, e.pageY, this._downX, this._downY, this._downTime)) { - if (this.onBrowseClickHandler()) { - this.onBrowseClickHandler().script.run({ documentView: this.DocumentView?.(), clientX: e.clientX, clientY: e.clientY }); - e.stopPropagation(); - e.preventDefault(); - } else if (this.isContentActive() && e.shiftKey) { + if (this.isContentActive() && e.shiftKey) { // reset zoom of freeform view to 1-to-1 on a shift + double click this.zoomSmoothlyAboutPt(this.screenToFreeformContentsXf.transformPoint(e.clientX, e.clientY), 1); e.stopPropagation(); @@ -1256,7 +1251,6 @@ export class CollectionFreeFormView extends CollectionSubView ); } + 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 @@ -1995,28 +2001,6 @@ class CollectionFreeFormOverlayView extends React.Component<{ elements: () => Vi return this.props.elements().filter(ele => ele.bounds?.z).map(ele => ele.ele); // prettier-ignore } } - -export function CollectionBrowseClick(dv: DocumentView, clientX: number, clientY: number) { - const browseTransitionTime = 500; - SelectionManager.DeselectAll(); - dv && - DocumentManager.Instance.showDocument(dv.Document, { zoomScale: 0.8, willZoomCentered: true }, (focused: boolean) => { - if (!focused) { - const selfFfview = !dv.Document.isGroup && dv.ComponentView instanceof CollectionFreeFormView ? dv.ComponentView : undefined; - const containers = dv.containerViewPath?.() ?? []; - let parFfview = dv.CollectionFreeFormView; - containers.forEach(cont => { - parFfview = parFfview ?? cont.CollectionFreeFormView; - }); - - while (parFfview?.Document.isGroup) parFfview = parFfview.DocumentView?.().CollectionFreeFormView; - const ffview = selfFfview && selfFfview.layoutDoc[selfFfview.scaleFieldKey] !== 0.5 ? selfFfview : parFfview; // if focus doc is a freeform that is not at it's default 0.5 scale, then zoom out on it. Otherwise, zoom out on the parent ffview - ffview?.zoomSmoothlyAboutPt(ffview.screenToFreeformContentsXf.transformPoint(clientX, clientY), ffview?.isAnnotationOverlay ? 1 : 0.5, browseTransitionTime); - Doc.linkFollowHighlight(dv?.Document, false); - } - }); -} -ScriptingGlobals.add(CollectionBrowseClick); // eslint-disable-next-line prefer-arrow-callback ScriptingGlobals.add(function nextKeyFrame(readOnly: boolean) { !readOnly && (SelectionManager.Views[0].ComponentView as CollectionFreeFormView)?.changeKeyFrame(); -- cgit v1.2.3-70-g09d2