From 4237c423cafea47ab11a593d5f150692a6b23d93 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 18 Nov 2020 19:09:29 +0100 Subject: clicking the nav bar jumps to that point --- .../frontend/app/views/viewer/nav/nav.parent.js | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/nav/nav.parent.js') diff --git a/animism-align/frontend/app/views/viewer/nav/nav.parent.js b/animism-align/frontend/app/views/viewer/nav/nav.parent.js index 5f1e173..6fc4b07 100644 --- a/animism-align/frontend/app/views/viewer/nav/nav.parent.js +++ b/animism-align/frontend/app/views/viewer/nav/nav.parent.js @@ -5,7 +5,7 @@ import actions from 'app/actions' import { ROMAN_NUMERALS } from 'app/constants' import { Arrow } from './viewer.icons' import NavPlayer from './nav.player' -import { thumbnailURL, sectionProgressPercentage } from 'app/utils/annotation.utils' +import { thumbnailURL, sectionProgressPercentage, sectionOffsetSeconds } from 'app/utils/annotation.utils' class NavParent extends Component { state = { @@ -15,12 +15,14 @@ class NavParent extends Component { } constructor(props){ super(props) + this.navbarRef = React.createRef() this.handleMouseMove = this.handleMouseMove.bind(this) this.handleMouseEnter = this.handleMouseEnter.bind(this) this.handleMouseLeave = this.handleMouseLeave.bind(this) this.handleMouseEnterNext = this.handleMouseEnterNext.bind(this) this.handleMouseLeaveNext = this.handleMouseLeaveNext.bind(this) this.handleNavBarClick = this.handleNavBarClick.bind(this) + this.handleSectionLinkClick = this.handleSectionLinkClick.bind(this) this.goToNextSection = this.goToNextSection.bind(this) } handleMouseEnter(){ @@ -51,8 +53,18 @@ class NavParent extends Component { } handleNavBarClick(e) { e && e.stopPropagation() - actions.viewer.toggleComponent('nav') // console.log('>> CLICK NAV') + // actions.viewer.toggleComponent('nav') + const percent = (e.pageX / this.navbarRef.current.offsetWidth) + const seconds = sectionOffsetSeconds(this.props.currentSection, percent) + console.log(e.pageX, this.navbarRef.current.offsetWidth, percent) + console.log(this.props.currentSection) + console.log(">>", seconds) + actions.viewer.seekToTimestamp(seconds) + } + handleSectionLinkClick(e) { + e && e.stopPropagation() + actions.viewer.toggleComponent('nav') } handleMouseMove(e) { e && e.stopPropagation() @@ -71,24 +83,24 @@ class NavParent extends Component { this.setState({ hoveringNext: false, hoveringNav: false, suppressHover: true }) } render() { - const { viewer, play_ts, started, playing } = this.props + const { viewer, currentSection, play_ts, started, playing } = this.props let containerClassName = "viewer-nav " + viewer.navStyle let navClassName = 'nav-row main-nav' if (this.state.hoveringNav || !started) containerClassName += ' hovering-nav' if ((this.state.hoveringNext || (viewer.atEndOfSection && !playing)) && !viewer.nav && viewer.nextSection) containerClassName += ' hovering-next' return ( -
+
- + - {viewer.currentSection && ( + {currentSection && ( viewer.mediaTitle ? {viewer.mediaTitle} : - {ROMAN_NUMERALS[viewer.currentSection.index]} + {ROMAN_NUMERALS[currentSection.index]} {'. '} - {viewer.currentSection.title} + {currentSection.title} )} @@ -99,11 +111,11 @@ class NavParent extends Component {
{viewer.nextSection ? "Next" @@ -113,7 +125,7 @@ class NavParent extends Component {
{viewer.nextSection && @@ -134,6 +146,7 @@ class NavParent extends Component { const mapStateToProps = state => ({ viewer: state.viewer, + currentSection: state.viewer.currentSection, started: state.audio.started, playing: state.audio.playing, play_ts: state.audio.play_ts, -- cgit v1.2.3-70-g09d2