diff options
| author | bob <bcz@cs.brown.edu> | 2019-06-14 16:25:58 -0400 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2019-06-14 16:25:58 -0400 |
| commit | e9d07e9d84ff5b0419b36f73768c8b8583fd0607 (patch) | |
| tree | b7d2e441217349db4ab1dafec0e46256c825b811 /src/client/views/nodes | |
| parent | 15e8341334419142f4a54db23cc643f18ba0e0f1 (diff) | |
| parent | 4a5fd3e230fe354dd6c579cad0d5f99a40d230db (diff) | |
Merge branch 'pdf_impl' of https://github.com/browngraphicslab/Dash-Web into pdf_impl
Diffstat (limited to 'src/client/views/nodes')
| -rw-r--r-- | src/client/views/nodes/PDFBox.tsx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index 899caa68a..b9ccd79e4 100644 --- a/src/client/views/nodes/PDFBox.tsx +++ b/src/client/views/nodes/PDFBox.tsx @@ -30,6 +30,15 @@ export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocumen @observable private _alt = false; @observable private _scrollY: number = 0; + private _reactionDisposer?: IReactionDisposer; + _targetDiv: any = undefined; + + componentDidMount: () => void = () => { + if (this._reactionDisposer) this._reactionDisposer(); + this._reactionDisposer = reaction(() => this.props.Document.scrollY, () => + this._targetDiv && this._targetDiv.scrollTo({ top: NumCast(this.Document.scrollY), behavior: "smooth" }) + ); + } loaded = (nw: number, nh: number) => { if (this.props.Document) { @@ -50,6 +59,7 @@ export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocumen @action onScroll = (e: React.UIEvent<HTMLDivElement>) => { if (e.currentTarget) { + this._targetDiv = e.currentTarget; this._scrollY = e.currentTarget.scrollTop; // e.currentTarget.scrollTo({ top: 1000, behavior: "smooth" }); let ccv = this.props.ContainingCollectionView; |
