aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/WebBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-02-11 18:11:57 -0500
committerbobzel <zzzman@gmail.com>2021-02-11 18:11:57 -0500
commit7dbd1417fe12b54cdab44fd25adb6c5a9c52bac9 (patch)
tree4489b776292679406f88f15a41d791c157931a07 /src/client/views/nodes/WebBox.tsx
parentf8008ec8d21f48591ba54a934022278c63852dba (diff)
more focus refactoring and some bug fixes - resetting target document when recursively focusing.
Diffstat (limited to 'src/client/views/nodes/WebBox.tsx')
-rw-r--r--src/client/views/nodes/WebBox.tsx10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 4dbf78e35..662477c05 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -111,9 +111,8 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
}
getAnchor = () => this.rootDoc;
- scrollFocus = (doc: Doc, smooth: boolean, willZoom?: boolean, scale?: number, afterFocus?: DocAfterFocusFunc) => {
- let focusSpeed = 0;
- let endFocus = afterFocus;
+ scrollFocus = (doc: Doc, smooth: boolean) => {
+ let focusSpeed: Opt<number>;
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) {
@@ -122,13 +121,12 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
this.goTo(scrollTo, focusSpeed = smooth ? 500 : 0);
this.layoutDoc._scrollTop = scrollTo;
this._ignoreScroll = false;
- endFocus = async (moved: boolean) => afterFocus ? await afterFocus(true) : false;
}
} else {
this._initialScroll = NumCast(doc.y);
}
- (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)));
+
+ return focusSpeed;
}
async componentDidMount() {