Prevent the control bar from changing when a touchstart or mousedown event is emitted on it

This commit is contained in:
DusuWen 2023-05-17 17:43:19 +08:00
parent cb1cadbc79
commit 9ca1c1ebd4
2 changed files with 7 additions and 3 deletions

View File

@ -122,11 +122,11 @@ class Controller {
percentage = Math.min(percentage, 1);
this.player.bar.set('played', percentage, 'width');
this.player.seek(this.player.bar.get('played') * this.player.video.duration);
this.player.timer.enable('progress');
this.player.moveBar = false;
};
this.player.template.playedBarWrap.addEventListener(utils.nameMap.dragStart, () => {
this.player.timer.disable('progress');
this.player.moveBar = true;
document.addEventListener(utils.nameMap.dragMove, thumbMove);
document.addEventListener(utils.nameMap.dragEnd, thumbUp);
});

View File

@ -182,6 +182,8 @@ class DPlayer {
this.play();
}
this.moveBar = false;
index++;
instances.push(this);
}
@ -537,7 +539,9 @@ class DPlayer {
});
this.on('timeupdate', () => {
this.bar.set('played', this.video.currentTime / this.video.duration, 'width');
if (!this.moveBar) {
this.bar.set('played', this.video.currentTime / this.video.duration, 'width');
}
const currentTime = utils.secondToTime(this.video.currentTime);
if (this.template.ptime.innerHTML !== currentTime) {
this.template.ptime.innerHTML = currentTime;