2017-05-16 23:37:17 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import SettingsDropdown from './component';
|
|
|
|
import Service 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',
|
|
|
|
];
|
2017-05-16 23:37:17 +08:00
|
|
|
|
|
|
|
fullscreenChangedEvents.forEach(event =>
|
|
|
|
document.addEventListener(event, this.handleFullscreenChange));
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
2017-05-19 22:25:24 +08:00
|
|
|
const fullscreenChangedEvents = [
|
|
|
|
'fullscreenchange',
|
|
|
|
'webkitfullscreenchange',
|
|
|
|
'mozfullscreenchange',
|
|
|
|
'MSFullscreenChange',
|
|
|
|
];
|
2017-05-16 23:37:17 +08:00
|
|
|
|
|
|
|
fullscreenChangedEvents.forEach(event =>
|
|
|
|
document.removeEventListener(event, this.fullScreenToggleCallback));
|
|
|
|
}
|
|
|
|
|
|
|
|
handleFullscreenChange() {
|
|
|
|
if (document.fullscreenElement
|
|
|
|
|| document.webkitFullscreenElement
|
|
|
|
|| document.mozFullScreenElement
|
|
|
|
|| document.msFullscreenElement) {
|
|
|
|
this.setState({ isFullScreen: true });
|
|
|
|
} else {
|
|
|
|
this.setState({ isFullScreen: false });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const handleToggleFullscreen = Service.toggleFullScreen;
|
|
|
|
const isFullScreen = this.state.isFullScreen;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SettingsDropdown
|
|
|
|
handleToggleFullscreen={handleToggleFullscreen}
|
|
|
|
isFullScreen={isFullScreen}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|