mirror of
https://github.com/videojs/video.js.git
synced 2024-12-10 11:10:19 +02:00
fix: remove extra timeupdate event when progress controls is disabled (#7142)
This commit is contained in:
parent
0cc8684120
commit
b2336aacc9
@ -5,6 +5,7 @@ import Component from '../../component.js';
|
||||
import * as Dom from '../../utils/dom.js';
|
||||
import clamp from '../../utils/clamp.js';
|
||||
import {bind, throttle, UPDATE_REFRESH_INTERVAL} from '../../utils/fn.js';
|
||||
import {silencePromise} from '../../utils/promise';
|
||||
|
||||
import './seek-bar.js';
|
||||
|
||||
@ -137,11 +138,23 @@ class ProgressControl extends Component {
|
||||
|
||||
this.off(['mousedown', 'touchstart'], this.handleMouseDown);
|
||||
this.off(this.el_, 'mousemove', this.handleMouseMove);
|
||||
this.handleMouseUp();
|
||||
|
||||
this.removeListenersAddedOnMousedownAndTouchstart();
|
||||
|
||||
this.addClass('disabled');
|
||||
|
||||
this.enabled_ = false;
|
||||
|
||||
// Restore normal playback state if controls are disabled while scrubbing
|
||||
if (this.player_.scrubbing()) {
|
||||
const seekBar = this.getChild('seekBar');
|
||||
|
||||
this.player_.scrubbing(false);
|
||||
|
||||
if (seekBar.videoWasPlaying) {
|
||||
silencePromise(this.player_.play());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,6 +174,18 @@ class ProgressControl extends Component {
|
||||
this.enabled_ = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup listeners after the user finishes interacting with the progress controls
|
||||
*/
|
||||
removeListenersAddedOnMousedownAndTouchstart() {
|
||||
const doc = this.el_.ownerDocument;
|
||||
|
||||
this.off(doc, 'mousemove', this.throttledHandleMouseSeek);
|
||||
this.off(doc, 'touchmove', this.throttledHandleMouseSeek);
|
||||
this.off(doc, 'mouseup', this.handleMouseUp);
|
||||
this.off(doc, 'touchend', this.handleMouseUp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle `mousedown` or `touchstart` events on the `ProgressControl`.
|
||||
*
|
||||
@ -194,17 +219,13 @@ class ProgressControl extends Component {
|
||||
* @listens mouseup
|
||||
*/
|
||||
handleMouseUp(event) {
|
||||
const doc = this.el_.ownerDocument;
|
||||
const seekBar = this.getChild('seekBar');
|
||||
|
||||
if (seekBar) {
|
||||
seekBar.handleMouseUp(event);
|
||||
}
|
||||
|
||||
this.off(doc, 'mousemove', this.throttledHandleMouseSeek);
|
||||
this.off(doc, 'touchmove', this.throttledHandleMouseSeek);
|
||||
this.off(doc, 'mouseup', this.handleMouseUp);
|
||||
this.off(doc, 'touchend', this.handleMouseUp);
|
||||
this.removeListenersAddedOnMousedownAndTouchstart();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user