aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-02-11 17:07:07 -0500
committerbobzel <zzzman@gmail.com>2021-02-11 17:07:07 -0500
commitf8008ec8d21f48591ba54a934022278c63852dba (patch)
treef053a0e74a374bbcfe541a8ac75c6e6c651e7b69 /src/client/views/pdf
parent890337b525ea460f9986562c047135bc5ca203a6 (diff)
now pdf/web/text scroll to the target and then pan the document to be in view.
Diffstat (limited to 'src/client/views/pdf')
-rw-r--r--src/client/views/pdf/PDFViewer.tsx14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index dd9dfa733..0429b61dc 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -180,17 +180,23 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
// scrolls to focus on a nested annotation document. if this is part a link preview then it will jump to the scroll location,
// otherwise it will scroll smoothly.
- scrollFocus = (doc: Doc, smooth: boolean, afterFocus?: DocAfterFocusFunc) => {
+ scrollFocus = (doc: Doc, smooth: boolean, willZoom?: boolean, scale?: number, afterFocus?: DocAfterFocusFunc) => {
const mainCont = this._mainCont.current;
+ let focusSpeed = 0;
+ let endFocus = afterFocus;
if (doc !== this.rootDoc && mainCont) {
const scrollTo = Utils.scrollIntoView(NumCast(doc.y), doc[HeightSym](), NumCast(this.layoutDoc._scrollTop), this.props.PanelHeight() / (this.props.scaling?.() || 1));
if (scrollTo !== undefined) {
- if (smooth) smoothScroll(500, mainCont, scrollTo);
+ focusSpeed = 500;
+
+ if (smooth) smoothScroll(focusSpeed, mainCont, scrollTo);
else mainCont.scrollTop = scrollTo;
- return afterFocus?.(true);
+
+ endFocus = async (moved: boolean) => afterFocus ? await afterFocus(true) : false;
}
}
- afterFocus?.(false);
+ (this.props as any).DocumentView().props.focus(this.rootDoc, willZoom, scale, (didFocus: boolean) =>
+ new Promise<boolean>(res => setTimeout(async () => res(endFocus ? await endFocus(didFocus) : false), focusSpeed)));
}
@action