forked from vguillou/fullscreen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfullscreen-api.html
54 lines (43 loc) · 1.73 KB
/
fullscreen-api.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
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="fullscreen-behavior.html">
<!--
A simple Polymer based Web Component wrapper for the HTML5 full screen API.
It lets you define which element to display in full screen mode
(via the `target` attribute) and toggle normal/full screen
mode by calling the `toggleFullscreen()` method.
Note that this method MUST be triggered directly by user interaction
(typically in a native `onclick` or Polymer's `on-click` handler).
If no `target` is set, the whole page (more specifically
`document.documentElement`) will be displayed full screen.
The element also provides 2 read-only flags as attribute:
- `fullscreenAvailable`: set to `true` if the browser supports
HTML5's full screen API (Safari on iOS does not).
- `fullscreen`: set to `true` if an element is currently displayed in
full screen mode.
Usage :
<template is="dom-bind">
<fullscreen-api id="fsapi" fullscreen-available="{{fullscreenAvailable}}"></fullscreen-api>
<button type="button" onclick="goFullscreen()" hidden$="[[!fullscreenAvailable]]">Display this page in full screen mode</button>
<div id="errorDiv" hidden$="[[fullscreenAvailable]]">
Your browser does not support the HTML5 full screen API... :(
</div>
</template>
<script>
function goFullscreen() {
var fsapi = document.querySelector('#fsapi');
fsapi.toggleFullscreen();
}
</script>
@element fullscreen-api
@blurb A simple Polymer based Web Component wrapper for the HTML5 full screen API.
@homepage https://github.com/vguillou/fullscreen-api
@demo demo/index.html
-->
<script>
Polymer({
is: "fullscreen-api",
behaviors: [
Polymer.FullscreenBehavior
]
});
</script>