import React, { Component } from 'react' // import { Link } from 'react-router-dom' import { connect } from 'react-redux' import actions from 'app/actions' import ViewerSectionsNav from './viewer.sections.nav' import { ROMAN_NUMERALS, CURTAIN_COLOR_LOOKUP } from 'app/constants' import { clamp, timestamp, floatInRange, floatLT } from 'app/utils' import { thumbnailURL, sectionProgressPercentage } from 'app/utils/annotation.utils' import { SpeakerIcon } from '../nav/viewer.icons' class ViewerSections extends Component { constructor(props) { super(props) this.scrollRef = React.createRef() this.handleWheel = this.handleWheel.bind(this) } shouldComponentUpdate(nextProps) { if (nextProps.nav !== this.props.nav) return true return nextProps.nav } handleWheel(e) { let delta = Math.abs(e.deltaY) > Math.abs(e.deltaX) ? e.deltaY : e.deltaX this.scrollRef.current.scrollLeft += delta } render() { const { play_ts, sections, currentSection } = this.props return (
this.handleWheel(e)} > {sections.map(section => { // console.log(section) const media = section.media.length ? section.media[0].media : null const { no_audio, section_nav_color } = section const progress = sectionProgressPercentage(section, play_ts) return (
actions.viewer.seekToSection(section)} >
{!no_audio &&
{timestamp(section.duration)}
{SpeakerIcon}
}
{ROMAN_NUMERALS[section.index]}
{section.title}
{section.mediaLabels}
) })}
) } } const mapStateToProps = state => ({ nav: state.viewer.nav, play_ts: state.audio.play_ts, sections: state.viewer.sections, currentSection: state.viewer.currentSection, }) export default connect(mapStateToProps)(ViewerSections)