Skip to content

Commit

Permalink
fix(FEC-7964): after first play the control bar is hidden on touch de…
Browse files Browse the repository at this point in the history
…vices (#198)

Previous logic shows the hover state on first time the player started to play.
But when we played entry with preload=auto it was still too early since props.prePlayback was still has true value in _updatePlayerHoverState what caused the method to terminate.
Change the implementation to when component did update with changes props from prePlayback to !prePlayback => show the hover state for the first time.
  • Loading branch information
Dan Ziv committed Mar 11, 2018
1 parent 5107421 commit 527289e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/components/shell/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,6 @@ class Shell extends BaseComponent {
this.props.updateDocumentWidth(document.body.clientWidth);
}
});
/**
* Handler for the first playing event - remove the listener and turn on the hover state.
* @returns {void}
*/
const onPlaying = () => {
this.player.removeEventListener(this.player.Event.PLAYING, onPlaying);
this._updatePlayerHoverState();
};
this.player.addEventListener(this.player.Event.CHANGE_SOURCE_STARTED, () => {
this.player.addEventListener(this.player.Event.PLAYING, onPlaying);
});
this.player.addEventListener(this.player.Event.PLAYING, onPlaying);
}

/**
Expand Down Expand Up @@ -262,6 +250,20 @@ class Shell extends BaseComponent {
}
}

/**
* when component did update and change its props from prePlayback to !prePlayback
* update the hover state
*
* @param {Object} prevProps - previous props
* @returns {void}
* @memberof Shell
*/
componentDidUpdate(prevProps: Object): void {
if (!this.props.prePlayback && prevProps.prePlayback) {
this._updatePlayerHoverState();
}
}

/**
* render component
*
Expand Down

0 comments on commit 527289e

Please sign in to comment.