Skip to content

Commit

Permalink
fix(FEC-10516): Fullscreen event dispatched twice from the player (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ziv authored Sep 30, 2020
1 parent 4e4a78f commit 359bb68
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fullscreen/fullscreen-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class FullscreenController {
_player: Player;
_isInBrowserFullscreen: boolean;
_eventManager: EventManager;
// Flag to overcome browsers which supports more than one fullscreenchange event
_isFullscreenEventDispatched: boolean = false;

/**
* after component mounted, set up event listeners to window fullscreen state change
Expand Down Expand Up @@ -244,7 +246,8 @@ class FullscreenController {
* @returns {void}
*/
_fullscreenEnterHandler(): void {
if (this.isFullscreen()) {
if (this.isFullscreen() && !this._isFullscreenEventDispatched) {
this._isFullscreenEventDispatched = true;
this._player.dispatchEvent(new FakeEvent(this._player.Event.ENTER_FULLSCREEN));
}
}
Expand All @@ -255,7 +258,8 @@ class FullscreenController {
* @returns {void}
*/
_fullscreenExitHandler(): void {
if (!this.isFullscreen()) {
if (!this.isFullscreen() && this._isFullscreenEventDispatched) {
this._isFullscreenEventDispatched = false;
this._eventManager.removeAll();
this._player.dispatchEvent(new FakeEvent(this._player.Event.EXIT_FULLSCREEN));
}
Expand Down

0 comments on commit 359bb68

Please sign in to comment.