This repository was archived by the owner on Apr 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathfullscreen.js
More file actions
54 lines (44 loc) · 1.54 KB
/
fullscreen.js
File metadata and controls
54 lines (44 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//exit full screen
let IS_APP_ON_FULL_SCREEN =false
const app = document.getElementById("app-wrap")
const videowrapper = document.getElementById("demo-wrap")
const controlswrapper = document.getElementById("controls-wrap")
if (app.addEventListener) {
app.addEventListener('webkitfullscreenchange', fullScreenHandler, false);
app.addEventListener('mozfullscreenchange', fullScreenHandler, false);
app.addEventListener('fullscreenchange', fullScreenHandler, false);
app.addEventListener('MSFullscreenChange', fullScreenHandler, false);
}
document.addEventListener("keydown", e => {
if (e.key == "F11") {
e.preventDefault()
app.requestFullscreen();
}
});
toogleFullscreen = () => {
app.requestFullscreen();
}
function fullScreenHandler() {
// If there's an element in fullscreen, exit
// Otherwise, enter it
if (!IS_APP_ON_FULL_SCREEN) {
// let app = document.getElementById("app")
// app.requestFullscreen();
appEnterFullscreen();
IS_APP_ON_FULL_SCREEN = true
} else {
appExitFullscreen();
IS_APP_ON_FULL_SCREEN = false;
}
}
function appExitFullscreen() {
app.classList.remove('app-wrap-fullscreen')
videowrapper.classList.remove('demo-wrap-fullscreen')
controlswrapper.classList.remove('controls-wrap-fullscreen')
}
function appEnterFullscreen() {
window.scrollTo(0, 0);
app.classList.add('app-wrap-fullscreen')
videowrapper.classList.add('demo-wrap-fullscreen')
controlswrapper.classList.add('controls-wrap-fullscreen')
}