aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf/PDFViewer.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-10-08 13:32:27 -0400
committerbobzel <zzzman@gmail.com>2020-10-08 13:32:27 -0400
commit4148b34504b51fade019389d7592cf825ddc0fa9 (patch)
treefda312644c1d046c0f1392cf4927242380ea27e1 /src/client/views/pdf/PDFViewer.tsx
parentf6623a790fbb5df02effebbe9edea69383e0569f (diff)
fixes for getting pdfs and previews to scroll properly
Diffstat (limited to 'src/client/views/pdf/PDFViewer.tsx')
-rw-r--r--src/client/views/pdf/PDFViewer.tsx23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 606d3e550..c669a5e5f 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -179,12 +179,25 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
(scrollY) => {
if (scrollY !== undefined) {
(this._showCover || this._showWaiting) && this.setupPdfJsViewer();
- if ((this.props.renderDepth === -1 || (!LinkDocPreview.TargetDoc && !FormattedTextBoxComment.linkDoc)) && this._mainCont.current) {
- smoothScroll(1000, this._mainCont.current, scrollY || 0);
- } else if (!LinkDocPreview.TargetDoc && !FormattedTextBoxComment.linkDoc) { // wait for mainCont and try again to scroll
- setTimeout(() => this._mainCont.current && smoothScroll(1000, this._mainCont.current, scrollY || 0), 250);
+ if (this.props.renderDepth !== -1 && !LinkDocPreview.TargetDoc && !FormattedTextBoxComment.linkDoc) {
+ const delay = this._mainCont.current ? 0 : 250; // wait for mainCont and try again to scroll
+ setTimeout(() => this._mainCont.current && smoothScroll(1000, this._mainCont.current, Math.abs(scrollY || 0)), delay);
+ setTimeout(() => { this.Document._scrollTop = scrollY; this.Document._scrollY = undefined; }, 1000 + delay);
+ }
+ }
+ },
+ { fireImmediately: true }
+ );
+ this._disposers.scrollPY = reaction(
+ () => Cast(this.Document._scrollPY, "number", null),
+ (scrollY) => {
+ if (scrollY !== undefined) {
+ (this._showCover || this._showWaiting) && this.setupPdfJsViewer();
+ if (this.props.renderDepth === -1 && scrollY >= 0) {
+ if (!this._mainCont.current) setTimeout(() => smoothScroll(1000, this._mainCont.current!, scrollY || 0));
+ else smoothScroll(1000, this._mainCont.current, scrollY || 0);
+ this.Document._scrollPY = undefined;
}
- setTimeout(() => { this.Document._scrollTop = scrollY; this.Document._scrollY = undefined; }, 1000);
}
},
{ fireImmediately: true }