bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/nav-bar/settings-dropdown/container.jsx

67 lines
1.7 KiB
React
Raw Normal View History

import React, { Component } from 'react';
2018-06-22 00:19:42 +08:00
import browser from 'browser-detect';
import SettingsDropdown from './component';
2018-05-09 05:37:58 +08:00
import { toggleFullScreen } from './service';
export default class SettingsDropdownContainer extends Component {
constructor(props) {
super(props);
this.state = {
isFullScreen: false,
};
this.handleFullscreenChange = this.handleFullscreenChange.bind(this);
}
componentDidMount() {
2017-05-19 22:25:24 +08:00
const fullscreenChangedEvents = [
'fullscreenchange',
'webkitfullscreenchange',
'mozfullscreenchange',
'MSFullscreenChange',
];
fullscreenChangedEvents.forEach(event =>
document.addEventListener(event, this.handleFullscreenChange));
}
componentWillUnmount() {
2017-05-19 22:25:24 +08:00
const fullscreenChangedEvents = [
'fullscreenchange',
'webkitfullscreenchange',
'mozfullscreenchange',
'MSFullscreenChange',
];
fullscreenChangedEvents.forEach(event =>
document.removeEventListener(event, this.fullScreenToggleCallback));
}
handleFullscreenChange() {
2018-05-09 05:37:58 +08:00
if (document.fullscreenElement
|| document.webkitFullscreenElement
|| document.mozFullScreenElement
|| document.msFullscreenElement) {
this.setState({ isFullScreen: true });
} else {
this.setState({ isFullScreen: false });
}
}
render() {
2018-05-05 01:31:01 +08:00
const handleToggleFullscreen = toggleFullScreen;
const isFullScreen = this.state.isFullScreen;
2018-06-22 00:19:42 +08:00
const result = browser();
const isAndroid = result.os.includes('Android');
return (
<SettingsDropdown
handleToggleFullscreen={handleToggleFullscreen}
isFullScreen={isFullScreen}
2018-06-22 00:19:42 +08:00
isAndroid={isAndroid}
/>
);
}
}