diff options
| author | bobzel <zzzman@gmail.com> | 2021-02-11 17:07:07 -0500 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2021-02-11 17:07:07 -0500 |
| commit | f8008ec8d21f48591ba54a934022278c63852dba (patch) | |
| tree | f053a0e74a374bbcfe541a8ac75c6e6c651e7b69 /src/client/views/collections/CollectionStackingView.tsx | |
| parent | 890337b525ea460f9986562c047135bc5ca203a6 (diff) | |
now pdf/web/text scroll to the target and then pan the document to be in view.
Diffstat (limited to 'src/client/views/collections/CollectionStackingView.tsx')
| -rw-r--r-- | src/client/views/collections/CollectionStackingView.tsx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index 9c12d5020..f100247c9 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -168,18 +168,23 @@ export class CollectionStackingView extends CollectionSubView<StackingDocument, return this.props.addDocTab(doc, where); } - focusDocument = (doc: Doc, willZoom?: boolean, scale?: number, afterFocus?: DocAfterFocusFunc) => { + focusDocument = (doc: Doc, willZoom?: boolean, scale?: number, afterFocus?: DocAfterFocusFunc, docTransform?: Transform) => { Doc.BrushDoc(doc); - this.props.focus(this.props.Document, true); // bcz: want our containing collection to zoom Doc.linkFollowHighlight(doc); + let focusSpeed = 0; const found = this._mainCont && Array.from(this._mainCont.getElementsByClassName("documentView-node")).find((node: any) => node.id === doc[Id]); if (found) { const top = found.getBoundingClientRect().top; const localTop = this.props.ScreenToLocalTransform().transformPoint(0, top); - smoothScroll(doc.presTransition || doc.presTransition === 0 ? NumCast(doc.presTransition) : 500, this._mainCont!, localTop[1] + this._mainCont!.scrollTop); + if (Math.floor(localTop[1]) !== 0) { + smoothScroll(focusSpeed = doc.presTransition || doc.presTransition === 0 ? NumCast(doc.presTransition) : 500, this._mainCont!, localTop[1] + this._mainCont!.scrollTop); + } } - afterFocus && setTimeout(afterFocus, 500); + const endFocus = async (moved: boolean) => afterFocus ? await afterFocus(moved) : false; + this.props.focus(this.rootDoc, willZoom, scale, (didFocus: boolean) => + new Promise<boolean>(res => setTimeout(async () => res(await endFocus(didFocus)), focusSpeed))); + } styleProvider = (doc: Doc | undefined, props: Opt<DocumentViewProps | FieldViewProps>, property: string) => { |
