2017-02-14 00:21:53 +08:00
|
|
|
|
|
|
|
toggleFullScreen = () => {
|
2017-04-19 04:00:50 +08:00
|
|
|
let element = document.documentElement;
|
2017-02-14 00:21:53 +08:00
|
|
|
|
2017-04-19 04:00:50 +08:00
|
|
|
if (document.fullscreenElement
|
|
|
|
|| document.webkitFullscreenElement
|
|
|
|
|| document.mozFullScreenElement
|
|
|
|
|| document.msFullscreenElement) {
|
2017-02-14 00:21:53 +08:00
|
|
|
|
2017-04-19 04:00:50 +08:00
|
|
|
if (document.exitFullscreen) {
|
|
|
|
document.exitFullscreen();
|
|
|
|
} else if (document.mozCancelFullScreen) {
|
|
|
|
document.mozCancelFullScreen();
|
|
|
|
} else if (document.webkitExitFullscreen) {
|
|
|
|
document.webkitExitFullscreen();
|
|
|
|
}
|
2017-02-14 00:21:53 +08:00
|
|
|
|
2017-04-19 04:00:50 +08:00
|
|
|
// If the page is not currently fullscreen, make fullscreen
|
|
|
|
} else {
|
|
|
|
if (element.requestFullscreen) {
|
|
|
|
element.requestFullscreen();
|
|
|
|
} else if (element.mozRequestFullScreen) {
|
|
|
|
element.mozRequestFullScreen();
|
|
|
|
} else if (element.webkitRequestFullscreen) {
|
|
|
|
element.webkitRequestFullscreen();
|
|
|
|
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
|
|
|
} else if (element.msRequestFullscreen) {
|
|
|
|
element.msRequestFullscreen();
|
|
|
|
}
|
|
|
|
}
|
2017-02-14 00:21:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export {
|
|
|
|
toggleFullScreen,
|
|
|
|
};
|