Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only change focus from BPB if not a mouse click #4497

Merged
merged 7 commits into from
Jul 26, 2017
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/js/big-play-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import Component from './component.js';
* @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`.
Expand All @@ -36,6 +43,11 @@ class BigPlayButton extends Button {
handleClick(event) {
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 playToggle = cb && cb.getChild('playToggle');

Expand All @@ -52,6 +64,16 @@ class BigPlayButton extends Button {
}, 1);
}
}

handleKeyPress(event) {
this.mouseused_ = false;

super.handleKeyPress(event);
}

handleMouseDown(event) {
this.mouseused_ = true;
}
}

/**
Expand Down