Skip to content

Commit

Permalink
feat(FEC-9613): allow application to disable double-click to fullscre…
Browse files Browse the repository at this point in the history
…en (#513)

* add `ui.components.fullscreen.disableDoubleClick` config and use it in the overlay-action component
* add missing component config types
  • Loading branch information
yairans committed Jun 2, 2020
1 parent 7057e62 commit 2d9df3b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 17 deletions.
5 changes: 4 additions & 1 deletion flow-typed/types/components-config.js
Expand Up @@ -2,5 +2,8 @@
declare type ComponentsConfig = {
seekbar?: SeekbarConfig,
watermark?: WatermarkConfig,
share?: ShareConfig
share?: ShareConfig,
vrStereo?: VrStereoConfig,
logo?: LogoConfig,
fullscreen?: FullscreenConfig
};
4 changes: 4 additions & 0 deletions flow-typed/types/fullscreen-config.js
@@ -0,0 +1,4 @@
// @flow
declare type FullscreenConfig = {
disableDoubleClick: boolean
};
6 changes: 6 additions & 0 deletions flow-typed/types/logo-config.js
@@ -0,0 +1,6 @@
// @flow
declare type LogoConfig = {
text: string,
url: string,
img: string
};
4 changes: 4 additions & 0 deletions flow-typed/types/vr-stereo-config.js
@@ -0,0 +1,4 @@
// @flow
declare type VrStereoConfig = {
vrStereoMode: boolean
};
34 changes: 19 additions & 15 deletions src/components/overlay-action/overlay-action.js
Expand Up @@ -21,7 +21,8 @@ const mapStateToProps = state => ({
iconType: state.overlayAction.iconType,
playerHover: state.shell.playerHover,
isMobile: state.shell.isMobile,
isSmartContainerOpen: state.shell.smartContainerOpen
isSmartContainerOpen: state.shell.smartContainerOpen,
fullscreenConfig: state.config.components.fullscreen
});

/**
Expand Down Expand Up @@ -181,21 +182,24 @@ class OverlayAction extends Component {
if (this.props.isSmartContainerOpen) {
return;
}
const now = Date.now();
if (now - this._firstClickTime < PLAY_PAUSE_BUFFER_TIME) {
this.cancelClickTimeout();
this.toggleFullscreen();
return;
}
if (now - this._firstClickTime < DOUBLE_CLICK_MAX_BUFFER_TIME) {
this.cancelClickTimeout();
this.togglePlayPause();
this.toggleFullscreen();
this._firstClickTime = 0;
return;
}
const {disableDoubleClick} = this.props.fullscreenConfig;
if (!disableDoubleClick) {
const now = Date.now();
if (now - this._firstClickTime < PLAY_PAUSE_BUFFER_TIME) {
this.cancelClickTimeout();
this.toggleFullscreen();
return;
}
if (now - this._firstClickTime < DOUBLE_CLICK_MAX_BUFFER_TIME) {
this.cancelClickTimeout();
this.togglePlayPause();
this.toggleFullscreen();
this._firstClickTime = 0;
return;
}

this._firstClickTime = now;
this._firstClickTime = now;
}
this._clickTimeout = setTimeout(() => {
this._clickTimeout = null;
this.togglePlayPause();
Expand Down
3 changes: 2 additions & 1 deletion src/reducers/config.js
Expand Up @@ -14,7 +14,8 @@ export const initialState = {
seekbar: {},
vrStereo: {},
share: {},
logo: {}
logo: {},
fullscreen: {}
}
};

Expand Down

0 comments on commit 2d9df3b

Please sign in to comment.