aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/WebBox.tsx
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/nodes/WebBox.tsx
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/nodes/WebBox.tsx')
-rw-r--r--src/client/views/nodes/WebBox.tsx11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index ef0df25b6..4dbf78e35 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -111,21 +111,24 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
}
getAnchor = () => this.rootDoc;
- scrollFocus = (doc: Doc, smooth: boolean, afterFocus?: DocAfterFocusFunc) => {
+ scrollFocus = (doc: Doc, smooth: boolean, willZoom?: boolean, scale?: number, afterFocus?: DocAfterFocusFunc) => {
+ let focusSpeed = 0;
+ let endFocus = afterFocus;
if (doc !== this.rootDoc && this.webpage && this._outerRef.current) {
const scrollTo = Utils.scrollIntoView(NumCast(doc.y), doc[HeightSym](), NumCast(this.layoutDoc._scrollTop), this.props.PanelHeight() / (this.props.scaling?.() || 1));
if (scrollTo !== undefined) {
this._initialScroll !== undefined && (this._initialScroll = scrollTo);
this._ignoreScroll = true;
- this.goTo(scrollTo, smooth ? 500 : 0);
+ this.goTo(scrollTo, focusSpeed = smooth ? 500 : 0);
this.layoutDoc._scrollTop = scrollTo;
this._ignoreScroll = false;
- return afterFocus?.(true);
+ endFocus = async (moved: boolean) => afterFocus ? await afterFocus(true) : false;
}
} else {
this._initialScroll = NumCast(doc.y);
}
- 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)));
}
async componentDidMount() {