This repository was archived by the owner on Oct 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFullScreenComponent.vue
More file actions
97 lines (94 loc) · 2.99 KB
/
FullScreenComponent.vue
File metadata and controls
97 lines (94 loc) · 2.99 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
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
<template>
<div class="hello">
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">ScreenFull-ES6 Demo</h1>
<p class="lead text-muted">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.</p>
</div>
</section>
<section class="container">
<div class="row justify-content-center">
<div class="col col-md-4" >
<div class="card mb-4 shadow " ref="card">
<img class="card-img-top" src="https://sindresorhus.com/unicorn" ref="image" @click="toggleImage">
<div class="card-body">
<h5 class="card-title">Try out the Fullscreen API.</h5>
<p class="card-text">Click the image to make it fullscreen</p>
<section>
<ul>
<li id="supported">Supported/allowed: {{ScreenFullEnabled}}</li>
<li id="status">Is fullscreen: {{fullscreen}}</li>
<li id="element">Element: {{element}}</li>
</ul>
</section>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button type="button" class="btn btn-sm btn-primary" @click="request">Request</button>
<button type="button" class="btn btn-sm btn-secondary" @click="exit">Exit</button>
<button type="button" class="btn btn-sm btn-success" @click="toggle">Toggle</button>
<button type="button" class="btn btn-sm btn-info" @click="requestDocument">Request document</button>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</template>
<script>
import ScreenFull from '../../../';
export default {
name: 'FullScreenComponent',
data() {
return {
element: '',
fullscreen: false
}
},
mounted() {
ScreenFull.on('change', this.fullscreenChange);
},
computed: {
/**
* @return {boolean}
*/
ScreenFullEnabled() {
return !!ScreenFull.enabled;
}
},
methods: {
request() {
ScreenFull.request(this.$refs.card);
},
exit() {
ScreenFull.exit();
},
toggle(){
ScreenFull.toggle(this.$refs.card);
},
toggleImage(){
ScreenFull.toggle(this.$refs.image);
},
requestDocument(){
ScreenFull.request();
},
fullscreenChange(){
this.fullscreen = ScreenFull.isFullscreen;
let elem = ScreenFull.element;
this.element = elem.localName + (elem.id ? '#' + elem.id : '');
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
#demo-img {
cursor: pointer;
}
.card {
width:340px;
}
</style>