From b737fa9a346082459cd746b7127db4984b350c04 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 20 Oct 2020 22:48:05 +0200 Subject: actually scrolling to footnotes --- .../app/views/viewer/sections/viewer.sections.footnotes.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/sections/viewer.sections.footnotes.js') diff --git a/animism-align/frontend/app/views/viewer/sections/viewer.sections.footnotes.js b/animism-align/frontend/app/views/viewer/sections/viewer.sections.footnotes.js index fa5142f..1582d82 100644 --- a/animism-align/frontend/app/views/viewer/sections/viewer.sections.footnotes.js +++ b/animism-align/frontend/app/views/viewer/sections/viewer.sections.footnotes.js @@ -14,6 +14,9 @@ class ViewerSectionsFootnotes extends Component { super(props) this.scrollRef = React.createRef() } + componentDidMount() { + this.cacheScrollPositions() + } componentDidUpdate(prevProps) { if (this.props.footnoteList !== prevProps.footnoteList) { this.cacheScrollPositions() @@ -30,8 +33,7 @@ class ViewerSectionsFootnotes extends Component { } scrollToFootnote() { const { currentFootnote } = this.props - const id = currentFootnote - 1 - const pos = this.state.scrollPositions[id] + const pos = this.state.scrollPositions[currentFootnote - 1] this.scrollRef.current.scrollTo(0, pos - 5) } render() { @@ -55,6 +57,7 @@ class ViewerSectionsFootnotes extends Component { ))} +
-- cgit v1.2.3-70-g09d2