Skip to content
Merged
Changes from all 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
12 changes: 12 additions & 0 deletions src/components/PlayPauseButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ class PlayPauseButton extends React.Component {

handleOnTouchStart = () => !isBrowser && this.props.togglePlay();

handleKeyDown = e => {
// Toggle play when user presses Enter
// The Space keypress event is ignored to avoid collision with the GlobalHotKeys
if (e.keyCode === 13) {
this.handleOnClick();
}
};

static getDerivedStateFromProps(nextProps, prevState) {
// set initial load to render the initial message accordingly
if (prevState.initialLoad && nextProps.playing) {
Expand All @@ -25,10 +33,14 @@ class PlayPauseButton extends React.Component {
render() {
return (
<div
aria-label={this.props.playing ? "Pause" : "Play"}
className={this.state.initialLoad ? "cta" : ""}
id="playContainer"
onClick={this.handleOnClick}
onKeyDown={this.handleKeyDown}
onTouchStart={this.handleOnTouchStart}
role="button"
tabIndex={0}
>
{this.props.playing ? <Pause /> : <Play />}
</div>
Expand Down