summaryrefslogtreecommitdiff
path: root/animism-align/frontend
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-11-06 19:21:59 +0100
committerJules Laplace <julescarbon@gmail.com>2020-11-06 19:21:59 +0100
commitd4ab7c7c02bc3a8beba64ebacfd14e3d838d1cac (patch)
treefc8d5bf6846ed5f116e9bd9047f324630338cc49 /animism-align/frontend
parent8469835531e4c207709749f7b19bc0aa181b5918 (diff)
defer video scrubber appearance to mouse movement. user must move the mouse at least 2 ticks.
Diffstat (limited to 'animism-align/frontend')
-rw-r--r--animism-align/frontend/app/views/viewer/player/components.media/video.scrubber.js25
1 files changed, 21 insertions, 4 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 fcc097a..e281559 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
@@ -19,21 +19,24 @@ class VideoScrubber extends Component {
this.handleMouseUp = this.handleMouseUp.bind(this)
this.handleMouseEnter = this.handleMouseEnter.bind(this)
this.handleMouseLeave = this.handleMouseLeave.bind(this)
+ this.handleWindowFocus = this.handleWindowFocus.bind(this)
this.hide = this.hide.bind(this)
}
componentDidMount() {
window.addEventListener('mousemove', this.handleMouseMove)
window.addEventListener('mouseup', this.handleMouseUp)
+ window.addEventListener('focus', this.handleWindowFocus)
// this.show()
}
componentWillUnmount() {
window.removeEventListener('mousemove', this.handleMouseMove)
window.removeEventListener('mouseup', this.handleMouseUp)
- clearTimeout(this.timeout)
+ window.removeEventListener('focus', this.handleWindowFocus)
+ clearTimeout(this.hideTimeout)
}
show() {
- clearTimeout(this.timeout)
- this.timeout = setTimeout(this.hide, VIDEO_SCRUBBER_HIDE_DELAY)
+ clearTimeout(this.hideTimeout)
+ this.hideTimeout = setTimeout(this.hide, VIDEO_SCRUBBER_HIDE_DELAY)
if (!this.showing) {
this.setState({ showing: true })
}
@@ -41,6 +44,7 @@ class VideoScrubber extends Component {
hide() {
clearTimeout(this.timeout)
this.setState({ showing: false })
+ this.defer = false
}
scrub(x, scrubbing) {
const { timing, start_ts, video_start_ts, onScrub, duration } = this.props
@@ -69,7 +73,16 @@ class VideoScrubber extends Component {
}
handleMouseMove(e) {
e.stopPropagation()
- this.show()
+ console.log('move', this.defer)
+ if (this.defer) {
+ this.defer = false
+ this.show()
+ }
+ this.defer = true
+ clearTimeout(this.showTimeout)
+ this.showTimeout = setTimeout(() => {
+ this.defer = false
+ }, 16)
if (!this.props.timing.scrubbing) return
this.scrub(e.pageX, true)
}
@@ -83,6 +96,10 @@ class VideoScrubber extends Component {
handleMouseLeave() {
this.setState({ hovering: false })
}
+ handleWindowFocus() {
+ this.setState({ showing: false, hovering: false })
+ clearTimeout(this.hideTimeout)
+ }
render() {
const { playing, start_ts, play_ts, volume, timing, video_start_ts, duration } = this.props
const { hovering, showing } = this.state