From c40b00512768088cefb591da7060d108d1d4764e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 23 Sep 2020 16:31:56 +0200 Subject: scrubber timestamp --- .../player/components.media/video.scrubber.js | 45 ++++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/player/components.media/video.scrubber.js') diff --git a/animism-align/frontend/app/views/viewer/player/components.media/video.scrubber.js b/animism-align/frontend/app/views/viewer/player/components.media/video.scrubber.js index 7bbbc07..53a93c3 100644 --- a/animism-align/frontend/app/views/viewer/player/components.media/video.scrubber.js +++ b/animism-align/frontend/app/views/viewer/player/components.media/video.scrubber.js @@ -6,20 +6,25 @@ import { clamp, timestamp } from 'app/utils' import { PlayButton, VolumeControl } from 'app/views/viewer/nav/viewer.icons' class VideoScrubber extends Component { + state = { + hovering: false, + } constructor(props) { super(props) this.scrubberRef = React.createRef() - this.handleScrubDotMouseDown = this.handleScrubDotMouseDown.bind(this) - this.handleScrubDotMouseMove = this.handleScrubDotMouseMove.bind(this) - this.handleScrubDotMouseUp = this.handleScrubDotMouseUp.bind(this) + this.handleMouseDown = this.handleMouseDown.bind(this) + this.handleMouseMove = this.handleMouseMove.bind(this) + this.handleMouseUp = this.handleMouseUp.bind(this) + this.handleMouseEnter = this.handleMouseEnter.bind(this) + this.handleMouseLeave = this.handleMouseLeave.bind(this) } componentDidMount() { - window.addEventListener('mousemove', this.handleScrubDotMouseMove) - window.addEventListener('mouseup', this.handleScrubDotMouseUp) + window.addEventListener('mousemove', this.handleMouseMove) + window.addEventListener('mouseup', this.handleMouseUp) } componentWillUnmount() { - window.removeEventListener('mousemove', this.handleScrubDotMouseMove) - window.removeEventListener('mouseup', this.handleScrubDotMouseUp) + window.removeEventListener('mousemove', this.handleMouseMove) + window.removeEventListener('mouseup', this.handleMouseUp) } scrub(x, scrubbing) { const { timing, start_ts, onScrub } = this.props @@ -32,21 +37,29 @@ class VideoScrubber extends Component { percent, seconds, scrubbing }) } - handleScrubDotMouseDown(e) { + handleMouseDown(e) { e.stopPropagation() this.scrub(e.pageX, true) } - handleScrubDotMouseMove(e) { + handleMouseMove(e) { e.stopPropagation() if (!this.props.timing.scrubbing) return this.scrub(e.pageX, true) } - handleScrubDotMouseUp(e) { + handleMouseUp(e) { e.stopPropagation() this.props.onScrub({ scrubbing: false }) } + handleMouseEnter() { + this.setState({ hovering: true }) + } + handleMouseLeave() { + this.setState({ hovering: false }) + } render() { const { playing, volume, timing } = this.props + const { hovering } = this.state + const timestampText = timestamp(clamp(timing.seconds, 0, timing.duration)) return (
@@ -54,7 +67,9 @@ class VideoScrubber extends Component {
@@ -62,10 +77,16 @@ class VideoScrubber extends Component { className='scrub-dot' style={{ left: (100 * timing.percent) + "%" }} /> +
+ {timestampText} +
- {timestamp(clamp(timing.seconds, 0, timing.duration))} + {timestampText}
-- cgit v1.2.3-70-g09d2