Skip to content

Commit

Permalink
Revert "Change audio/video playback to stop playback when out of view (
Browse files Browse the repository at this point in the history
  • Loading branch information
umonaca committed May 14, 2020
1 parent 99ac41f commit 2568dab
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 34 deletions.
17 changes: 0 additions & 17 deletions app/javascript/mastodon/features/audio/index.js
Expand Up @@ -60,8 +60,6 @@ class Audio extends React.PureComponent {
if (this.waveform) {
this._updateWaveform();
}

window.addEventListener('scroll', this.handleScroll);
}

componentDidUpdate (prevProps) {
Expand All @@ -71,8 +69,6 @@ class Audio extends React.PureComponent {
}

componentWillUnmount () {
window.removeEventListener('scroll', this.handleScroll);

if (this.wavesurfer) {
this.wavesurfer.destroy();
this.wavesurfer = null;
Expand Down Expand Up @@ -178,19 +174,6 @@ class Audio extends React.PureComponent {
}
}, 60);

handleScroll = throttle(() => {
if (!this.waveform || !this.wavesurfer) {
return;
}

const { top, height } = this.waveform.getBoundingClientRect();
const inView = (top <= (window.innerHeight || document.documentElement.clientHeight)) && (top + height >= 0);

if (!this.state.paused && !inView) {
this.setState({ paused: true }, () => this.wavesurfer.pause());
}
}, 150, { trailing: true })

render () {
const { height, intl, alt, editable } = this.props;
const { paused, muted, volume, currentTime } = this.state;
Expand Down
17 changes: 0 additions & 17 deletions app/javascript/mastodon/features/video/index.js
Expand Up @@ -279,16 +279,12 @@ class Video extends React.PureComponent {
document.addEventListener('mozfullscreenchange', this.handleFullscreenChange, true);
document.addEventListener('MSFullscreenChange', this.handleFullscreenChange, true);

window.addEventListener('scroll', this.handleScroll);

if (this.props.blurhash) {
this._decode();
}
}

componentWillUnmount () {
window.removeEventListener('scroll', this.handleScroll);

document.removeEventListener('fullscreenchange', this.handleFullscreenChange, true);
document.removeEventListener('webkitfullscreenchange', this.handleFullscreenChange, true);
document.removeEventListener('mozfullscreenchange', this.handleFullscreenChange, true);
Expand Down Expand Up @@ -325,19 +321,6 @@ class Video extends React.PureComponent {
}
}

handleScroll = throttle(() => {
if (!this.video) {
return;
}

const { top, height } = this.video.getBoundingClientRect();
const inView = (top <= (window.innerHeight || document.documentElement.clientHeight)) && (top + height >= 0);

if (!this.state.paused && !inView) {
this.setState({ paused: true }, () => this.video.pause());
}
}, 150, { trailing: true })

handleFullscreenChange = () => {
this.setState({ fullscreen: isFullscreen() });
}
Expand Down

0 comments on commit 2568dab

Please sign in to comment.