diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-09-23 16:31:56 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-09-23 16:31:56 +0200 |
| commit | c40b00512768088cefb591da7060d108d1d4764e (patch) | |
| tree | f50e2455e6e1392635c789de5bb97d66903c497f /animism-align/frontend/app/views/viewer/player/components.media/video.scrubber.js | |
| parent | 9f707dfa8c0b2d38d4d81c1cf0df38df494a49b2 (diff) | |
scrubber timestamp
Diffstat (limited to 'animism-align/frontend/app/views/viewer/player/components.media/video.scrubber.js')
| -rw-r--r-- | animism-align/frontend/app/views/viewer/player/components.media/video.scrubber.js | 45 |
1 files changed, 33 insertions, 12 deletions
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 ( <div className='video-scrubber'> <div className='start-controls'> @@ -54,7 +67,9 @@ class VideoScrubber extends Component { </div> <div className='scrub-bar-container' - onMouseDown={this.handleScrubDotMouseDown} + onMouseDown={this.handleMouseDown} + onMouseEnter={this.handleMouseEnter} + onMouseLeave={this.handleMouseLeave} ref={this.scrubberRef} > <div className='scrub-bar' /> @@ -62,10 +77,16 @@ class VideoScrubber extends Component { className='scrub-dot' style={{ left: (100 * timing.percent) + "%" }} /> + <div + className='scrub-timestamp' + style={{ left: (100 * (timing.percent)) + "%" }} + > + {timestampText} + </div> </div> <div className='end-controls'> <div className='playerTime'> - {timestamp(clamp(timing.seconds, 0, timing.duration))} + {timestampText} </div> <VolumeControl volume={volume} /> </div> |
