1
0
mirror of https://github.com/videojs/video.js.git synced 2025-05-29 23:17:35 +02:00

feat(player): add option to disable or override double-click handling. (#5611)

`userActions.doubleClick` can be set to false to disable double click to fullscreen. Can be set to a function to override behavior.

Fixes #5604.
This commit is contained in:
Owen Edwards 2019-01-25 11:18:33 -08:00 committed by Gary Katsevman
parent 61053bf674
commit e8909231bd
2 changed files with 50 additions and 4 deletions

View File

@ -36,6 +36,7 @@
* [techCanOverridePoster](#techcanoverrideposter)
* [techOrder](#techorder)
* [userActions](#useractions)
* [userActions.doubleClick](#useractions.doubleclick)
* [userActions.hotkeys](#useractions.hotkeys)
* [userActions.hotkeys.fullscreenKey](#useractions.hotkeys.fullscreenkey)
* [userActions.hotkeys.muteKey](#useractions.hotkeys.mutekey)
@ -376,6 +377,28 @@ Defines the order in which Video.js techs are preferred. By default, this means
> Type: `Object`
### `userActions.doubleClick`
> Type: `boolean|function`
Controls how double-clicking on the player/tech operates. If set to `false`, double-clicking is disabled. If undefined or set to
`true`, double-clicking is enabled and toggles fullscreen mode. To override the default double-click handling, set `userActions.doubleClick`
to a function which accepts a `dblclick` event:
```js
function myDoubleClickHandler(event) = {
// `this` is the player in this context
this.pause();
};
videojs('my-player', {
userActions: {
doubleClick: myDoubleClickHandler
}
});
```
### `userActions.hotkeys`
> Type: `boolean|function|object`

View File

@ -1855,10 +1855,33 @@ class Player extends Component {
);
if (!inAllowedEls) {
if (this.isFullscreen()) {
this.exitFullscreen();
} else {
this.requestFullscreen();
/*
* options.userActions.doubleClick
*
* If `undefined` or `true`, double-click toggles fullscreen if controls are present
* Set to `false` to disable double-click handling
* Set to a function to substitute an external double-click handler
*/
if (
this.options_ === undefined ||
this.options_.userActions === undefined ||
this.options_.userActions.doubleClick === undefined ||
this.options_.userActions.doubleClick !== false
) {
if (
this.options_ !== undefined &&
this.options_.userActions !== undefined &&
typeof this.options_.userActions.doubleClick === 'function'
) {
this.options_.userActions.doubleClick.call(this, event);
} else if (this.isFullscreen()) {
this.exitFullscreen();
} else {
this.requestFullscreen();
}
}
}
}