mirror of
https://github.com/videojs/video.js.git
synced 2025-01-27 11:22:06 +02:00
fix: only change focus from BPB if not a mouse click (#4497)
This commit is contained in:
parent
fe95a7720a
commit
ee014e2e04
@ -11,6 +11,13 @@ import Component from './component.js';
|
|||||||
* @extends Button
|
* @extends Button
|
||||||
*/
|
*/
|
||||||
class BigPlayButton extends Button {
|
class BigPlayButton extends Button {
|
||||||
|
constructor(player, options) {
|
||||||
|
super(player, options);
|
||||||
|
|
||||||
|
this.mouseused_ = false;
|
||||||
|
|
||||||
|
this.on('mousedown', this.handleMouseDown);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the default DOM `className`.
|
* Builds the default DOM `className`.
|
||||||
@ -36,6 +43,11 @@ class BigPlayButton extends Button {
|
|||||||
handleClick(event) {
|
handleClick(event) {
|
||||||
const playPromise = this.player_.play();
|
const playPromise = this.player_.play();
|
||||||
|
|
||||||
|
// exit early if clicked via the mouse
|
||||||
|
if (this.mouseused_ && event.clientX && event.clientY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const cb = this.player_.getChild('controlBar');
|
const cb = this.player_.getChild('controlBar');
|
||||||
const playToggle = cb && cb.getChild('playToggle');
|
const playToggle = cb && cb.getChild('playToggle');
|
||||||
|
|
||||||
@ -44,14 +56,26 @@ class BigPlayButton extends Button {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playPromise) {
|
const playFocus = () => playToggle.focus();
|
||||||
playPromise.then(() => playToggle.focus());
|
|
||||||
|
if (playPromise && playPromise.then) {
|
||||||
|
const ignoreRejectedPlayPromise = () => {};
|
||||||
|
|
||||||
|
playPromise.then(playFocus, ignoreRejectedPlayPromise);
|
||||||
} else {
|
} else {
|
||||||
this.setTimeout(function() {
|
this.setTimeout(playFocus, 1);
|
||||||
playToggle.focus();
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleKeyPress(event) {
|
||||||
|
this.mouseused_ = false;
|
||||||
|
|
||||||
|
super.handleKeyPress(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMouseDown(event) {
|
||||||
|
this.mouseused_ = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user