improve adding and removing of events

This commit is contained in:
KDSBrowne 2017-03-16 17:06:34 -07:00
parent 1de05d1f23
commit c6e08c5518

View File

@ -17,17 +17,23 @@ export default class SettingsDropdownContainer extends Component {
}
componentDidMount() {
document.addEventListener("fullscreenchange", this.fullScreenToggleCallback);
    document.addEventListener("webkitfullscreenchange", this.fullScreenToggleCallback);
    document.addEventListener("mozfullscreenchange", this.fullScreenToggleCallback);
    document.addEventListener("MSFullscreenChange", this.fullScreenToggleCallback);
const fullscreenChangedEvents = ['fullscreenchange',
'webkitfullscreenchange',
'mozfullscreenchange',
'MSFullscreenChange'];
fullscreenChangedEvents.forEach(event =>
document.addEventListener(event, this.fullScreenToggleCallback));
}
componentWillUnmount() {
document.removeEventListener("fullscreenchange", this.fullScreenToggleCallback);
    document.removeEventListener("webkitfullscreenchange", this.fullScreenToggleCallback);
    document.removeEventListener("mozfullscreenchange", this.fullScreenToggleCallback);
    document.removeEventListener("MSFullscreenChange", this.fullScreenToggleCallback);
const fullscreenChangedEvents = ['fullscreenchange',
'webkitfullscreenchange',
'mozfullscreenchange',
'MSFullscreenChange'];
fullscreenChangedEvents.forEach(event =>
document.removeEventListener(event, this.fullScreenToggleCallback));
}
fullScreenToggleCallback() {