Skip to content

Commit d133de0

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

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
@@ -277,16 +277,12 @@ class Video extends React.PureComponent {
277277
document.addEventListener('mozfullscreenchange', this.handleFullscreenChange, true);
278278
document.addEventListener('MSFullscreenChange', this.handleFullscreenChange, true);
279279

280-
window.addEventListener('scroll', this.handleScroll);
281-
282280
if (this.props.blurhash) {
283281
this._decode();
284282
}
285283
}
286284

287285
componentWillUnmount () {
288-
window.removeEventListener('scroll', this.handleScroll);
289-
290286
document.removeEventListener('fullscreenchange', this.handleFullscreenChange, true);
291287
document.removeEventListener('webkitfullscreenchange', this.handleFullscreenChange, true);
292288
document.removeEventListener('mozfullscreenchange', this.handleFullscreenChange, true);
@@ -323,19 +319,6 @@ class Video extends React.PureComponent {
323319
}
324320
}
325321

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

0 commit comments

Comments
 (0)