diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-11-21 16:44:07 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-11-21 16:44:07 +0100 |
| commit | 49bf241d0fa275053424db3458a057de7b9d418f (patch) | |
| tree | 8df9a9c5748c2bece60de2403d1cddbe0cd56b56 /animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js | |
| parent | ee04ccd494b8a2dd1e535168979596c9907cd0ab (diff) | |
messaging if rest of chapters are disabled. grayscale all disabled media
Diffstat (limited to 'animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js')
| -rw-r--r-- | animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js | 29 |
1 files changed, 25 insertions, 4 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 0d34a45..8fc1238 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 @@ -2,7 +2,7 @@ import React, { Component } from 'react' import { connect } from 'react-redux' import actions from 'app/actions' -import { ROMAN_NUMERALS } from 'app/constants' +import { ROMAN_NUMERALS, SECTION_LIMITED_MESSAGE } from 'app/constants' import { timestamp } from 'app/utils' import { thumbnailURL, sectionProgressPercentage } from 'app/utils/annotation.utils' import { SpeakerIcon } from '../nav/viewer.icons' @@ -10,6 +10,9 @@ import { SpeakerIcon } from '../nav/viewer.icons' const SECTION_WIDTH = 13 * 16 class ViewerSectionsList extends Component { + state = { + selectedSectionIndex: -1, + } constructor(props) { super(props) this.scrollRef = React.createRef() @@ -33,8 +36,20 @@ class ViewerSectionsList extends Component { let delta = Math.abs(e.deltaY) > Math.abs(e.deltaX) ? e.deltaY : e.deltaX this.scrollRef.current.scrollLeft += delta } + handleSectionClick(e, section) { + if (this.props.onlyEnableFirstSection) { + this.setState({ selectedSectionIndex: section.index }) + clearTimeout(this.warningFadeTimeout) + this.warningFadeTimeout = setTimeout(() => { + this.setState({ selectedSectionIndex: -1 }) + }, 10000) + } else { + actions.viewer.seekToSection(section) + } + } render() { - const { play_ts, sections, media, currentSection } = this.props + const { play_ts, sections, media, currentSection, onlyEnableFirstSection } = this.props + const { selectedSectionIndex } = this.state return ( <div ref={this.scrollRef} @@ -55,9 +70,9 @@ class ViewerSectionsList extends Component { <div className={(!currentSection || section.index === currentSection.index) ? "viewer-section current-section" : "viewer-section"} key={section.index} - onClick={() => actions.viewer.seekToSection(section)} + onClick={e => this.handleSectionClick(e, section)} > - <div> + <div className="section-content"> <div className="section-thumbnail" style={{ backgroundImage: mediaItem && 'url(' + thumbnailURL(mediaItem) + ')', }}> @@ -85,6 +100,11 @@ class ViewerSectionsList extends Component { {section.mediaLabels} </div> </div> + {!!(onlyEnableFirstSection && section.index) && ( + <div className={section.index === selectedSectionIndex ? 'section-limited visible' : 'section-limited'}> + {SECTION_LIMITED_MESSAGE} + </div> + )} </div> ) })} @@ -96,6 +116,7 @@ class ViewerSectionsList extends Component { const mapStateToProps = state => ({ media: state.media.index, nav: state.viewer.nav, + onlyEnableFirstSection: state.viewer.onlyEnableFirstSection, play_ts: state.audio.play_ts, sections: state.viewer.sections, currentSection: state.viewer.currentSection, |
