-
-
Notifications
You must be signed in to change notification settings - Fork 698
/
index.html
194 lines (165 loc) · 4.5 KB
/
index.html
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!doctype html>
<html lang="en" itemscope itemtype="https://schema.org/Product">
<head>
<meta charset="utf-8">
<meta name="author" content="Sindre Sorhus">
<meta name="description" content="JavaScript Fullscreen API demo">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta itemprop="name" content="screenfull">
<meta itemprop="description" content="Simple wrapper for cross-browser usage of the JavaScript Fullscreen API, which lets you bring the page or any element into fullscreen. Smoothens out the browser implementation differences, so you don't have too.">
<title>screenfull demo</title>
<style>
html {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding: 30px 10px 0 0;
font-size: 20px;
line-height: 1.4;
color: #737373;
background: #f0f0f0;
-webkit-font-smoothing: antialiased;
}
hr {
border: none;
border-top: 1px solid #e6e6e6;
margin: 20px 0;
}
a {
color: #666;
}
h1 {
margin: 0;
font-size: 40px;
text-align: center;
}
h1 span {
color: #bbb;
}
ul {
padding: 0 0 0 40px;
margin: 1em 0;
}
button {
font-size: 13px;
}
nav {
margin: 0 auto;
}
.container {
width: 500px;
margin: 0 auto;
}
#repo-link {
text-align: center;
text-decoration: none;
display: block;
position: absolute;
top: 20px;
left: 20px;
}
#social {
margin: 10px auto;
text-align: center;
}
#container {
width: 500px;
padding: 30px 20px;
margin: 0 auto 50px auto;
background: #fcfcfc;
text-align: center;
border: 1px solid #b3b3b3;
border-radius: 4px;
box-shadow: 0 1px 10px #a7a7a7, inset 0 1px 0 #fff;
}
#container ul {
padding: 0;
margin: 40px 0 0 0;
list-style: none;
}
#demo-img {
width: 100%;
height: auto;
}
#demo-img,
#demo-video {
cursor: pointer;
}
header p {
font-size: 17px;
}
</style>
</head>
<body>
<a id="repo-link" href="https://github.com/sindresorhus/screenfull">⬅ Back to the repo</a>
<section id="container" class="container">
<header>
<h1>screenfull<span>.js</span></h1>
<p>Simple wrapper for cross-browser usage of the JavaScript <a href="https://developer.mozilla.org/en/DOM/Using_full-screen_mode">Fullscreen API</a>, which lets you bring the page or any element into fullscreen. Smoothens out the browser implementation differences, so you don't have too.</p>
</header>
<hr>
<section>
<p>Try out the Fullscreen API</p>
<button id="request">Request</button>
<button id="exit">Exit</button>
<button id="toggle">Toggle</button>
<button id="request2">Request document</button>
</section>
<section>
<ul>
<li id="supported"></li>
<li id="status"></li>
<li id="element"></li>
</ul>
</section>
<input autofocus placeholder="Keyboard test">
<hr>
<section>
<p>Click the image to make it fullscreen</p>
<img id="demo-img" src="https://sindresorhus.com/unicorn" width="500">
</section>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="module">
import screenfull from './index.js';
$(function () {
$('#supported').text(`Supported/allowed: ${screenfull.isEnabled}`);
if (!screenfull.isEnabled) {
return false;
}
$('#request').click(async () => {
await screenfull.request($('#container')[0]);
console.log('Browser entered fullscreen mode');
// Does not require jQuery. Can be used like this too:
// screenfull.request(document.getElementById('container'));
});
$('#exit').click(async () => {
await screenfull.exit();
console.log('Browser exited fullscreen mode');
});
$('#toggle').click(async () => {
await screenfull.toggle($('#container')[0]);
console.log(`Fullscreen mode: ${screenfull.isFullscreen ? 'enabled' : 'disabled'}`);
});
$('#request2').click(() => {
screenfull.request();
});
$('#demo-img').click(() => {
screenfull.toggle($('#demo-img')[0]);
});
function fullscreenchange() {
const {element} = screenfull;
$('#status').text(`Is fullscreen: ${screenfull.isFullscreen}`);
if (element) {
$('#element').text(`Element: ${element.localName}${element.id ? `#${element.id}` : ''}`);
}
if (!screenfull.isFullscreen) {
$('#external-iframe').remove();
document.body.style.overflow = 'auto';
}
}
screenfull.on('change', fullscreenchange);
// Set the initial values
fullscreenchange();
});
</script>
</body>
</html>