Skip to content

Commit 2568dab

Browse files
committed
Revert "Change audio/video playback to stop playback when out of view (mastodon#12486)"
1 parent 99ac41f commit 2568dab

2 files changed

Lines changed: 0 additions & 34 deletions

File tree

app/javascript/mastodon/features/audio/index.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ class Audio extends React.PureComponent {
6060
if (this.waveform) {
6161
this._updateWaveform();
6262
}
63-
64-
window.addEventListener('scroll', this.handleScroll);
6563
}
6664

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

7371
componentWillUnmount () {
74-
window.removeEventListener('scroll', this.handleScroll);
75-
7672
if (this.wavesurfer) {
7773
this.wavesurfer.destroy();
7874
this.wavesurfer = null;
@@ -178,19 +174,6 @@ class Audio extends React.PureComponent {
178174
}
179175
}, 60);
180176

181-
handleScroll = throttle(() => {
182-
if (!this.waveform || !this.wavesurfer) {
183-
return;
184-
}
185-
186-
const { top, height } = this.waveform.getBoundingClientRect();
187-
const inView = (top <= (window.innerHeight || document.documentElement.clientHeight)) && (top + height >= 0);
188-
189-
if (!this.state.paused && !inView) {
190-
this.setState({ paused: true }, () => this.wavesurfer.pause());
191-
}
192-
}, 150, { trailing: true })
193-
194177
render () {
195178
const { height, intl, alt, editable } = this.props;
196179
const { paused, muted, volume, currentTime } = this.state;

app/javascript/mastodon/features/video/index.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,12 @@ class Video extends React.PureComponent {
279279
document.addEventListener('mozfullscreenchange', this.handleFullscreenChange, true);
280280
document.addEventListener('MSFullscreenChange', this.handleFullscreenChange, true);
281281

282-
window.addEventListener('scroll', this.handleScroll);
283-
284282
if (this.props.blurhash) {
285283
this._decode();
286284
}
287285
}
288286

289287
componentWillUnmount () {
290-
window.removeEventListener('scroll', this.handleScroll);
291-
292288
document.removeEventListener('fullscreenchange', this.handleFullscreenChange, true);
293289
document.removeEventListener('webkitfullscreenchange', this.handleFullscreenChange, true);
294290
document.removeEventListener('mozfullscreenchange', this.handleFullscreenChange, true);
@@ -325,19 +321,6 @@ class Video extends React.PureComponent {
325321
}
326322
}
327323

328-
handleScroll = throttle(() => {
329-
if (!this.video) {
330-
return;
331-
}
332-
333-
const { top, height } = this.video.getBoundingClientRect();
334-
const inView = (top <= (window.innerHeight || document.documentElement.clientHeight)) && (top + height >= 0);
335-
336-
if (!this.state.paused && !inView) {
337-
this.setState({ paused: true }, () => this.video.pause());
338-
}
339-
}, 150, { trailing: true })
340-
341324
handleFullscreenChange = () => {
342325
this.setState({ fullscreen: isFullscreen() });
343326
}

0 commit comments

Comments
 (0)