summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-11-18 16:11:16 +0100
committerJules Laplace <julescarbon@gmail.com>2020-11-18 16:11:16 +0100
commita8be1abd5329ed6d52f0b565284cd0d41267e57a (patch)
tree7537c3d0e24a21a14407f59be3f0f4443468a468 /animism-align/frontend/app/views
parente7831cdb9f133e2ba665d726106503daa0e7b85c (diff)
auto-scroll sections list
Diffstat (limited to 'animism-align/frontend/app/views')
-rw-r--r--animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js b/animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js
index fd7ade4..3ce1cc1 100644
--- a/animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js
+++ b/animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js
@@ -7,6 +7,8 @@ import { timestamp } from 'app/utils'
import { thumbnailURL, sectionProgressPercentage } from 'app/utils/annotation.utils'
import { SpeakerIcon } from '../nav/viewer.icons'
+const SECTION_WIDTH = 13 * 16
+
class ViewerSectionsList extends Component {
constructor(props) {
super(props)
@@ -14,9 +16,18 @@ class ViewerSectionsList extends Component {
this.handleWheel = this.handleWheel.bind(this)
}
shouldComponentUpdate(nextProps) {
+ if (this.props.currentSection !== nextProps.currentSection) {
+ this.scrollToSection(nextProps.currentSection)
+ }
if (nextProps.nav !== this.props.nav) return true
return nextProps.nav
}
+ scrollToSection(section) {
+ const dx = section.index * SECTION_WIDTH
+ setTimeout(() => {
+ this.scrollRef.current.scrollTo(dx, 0)
+ }, 500)
+ }
handleWheel(e) {
let delta = Math.abs(e.deltaY) > Math.abs(e.deltaX) ? e.deltaY : e.deltaX
this.scrollRef.current.scrollLeft += delta