Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

Commit cbc6389

Browse files
committed
Updates to fullscreen article #484
1 parent 16a06f3 commit cbc6389

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

content/mobile/fullscreen/en/index.html

+34-30
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
}
1616
.talkinghead-pk:before {
1717
background-image:url(/static/images/profiles/paulkinlan.png);
18+
background-size: 60px 60px;
1819
background-position:0px 0px!important;
1920
}
2021
</style>
@@ -72,17 +73,21 @@ <h3 id="toc-request">Requesting Full Screen</h3>
7273
<p>The main JS API’s that you need to care about when building an app or a site that uses full screen API are:</p>
7374

7475
<ul>
75-
<li>[element].requestFullscreen() (currently prefixed for both Blink and Gecko) it will take the element and make it full screen.</li>
76-
<li>document.cancelFullscreen() (currently prefixed for both Blink and Gecko) it will cancel full screen mode.</li>
77-
<li>document.fullscreenElement (currently prefixed for both Blink and Gecko) is used to determine if any of the elements are in full screen mode.</li>
76+
<li><pre>[element].requestFullscreen()</pre> (currently prefixed for both Blink and Gecko) it will take the element and make it full screen.</li>
77+
<li><pre>document.cancelFullscreen()</pre> (currently prefixed for both Blink and Gecko) it will cancel full screen mode.</li>
78+
<li><pre>document.fullscreenElement</pre> (currently prefixed for both Blink and Gecko) is used to determine if any of the elements are in full screen mode.</li>
7879
</ul>
7980

81+
<blockquote class="commentary talkinghead talkinghead-pk">
82+
You will notice that in the prefixed versions there is a lot of inconsitency between the casing of the 'S' in screen. This is awkward, but this is the problem with specs that are inflight.
83+
</blockquote>
84+
8085
<p>When your app is full-screen you no longer have the browser chrome available to you. This changes the way that users interact with your experience, they will not have the standard navigation controls such as forwards and backwards, nor will they have their escape hatch refresh button. It is important to cater for this scenario. You can use some CSS selectors to help you change the style and presentation of your site when the browser enters full screen mode.</p>
8186

82-
<pre class="prettyprint">&lt;button id=goFS>Go full screen&lt;button>
87+
<pre class="prettyprint">&lt;button id="goFS">Go full screen&lt;button>
8388
&lt;script>
84-
var goFS = document.getElementById(goFS);
85-
goFS.addEventListener(click, function() {
89+
var goFS = document.getElementById("goFS");
90+
goFS.addEventListener("click", function() {
8691
document.body.requestFullScreen();
8792
}, false);
8893
&lt;/script></pre>
@@ -93,7 +98,7 @@ <h3 id="toc-request">Requesting Full Screen</h3>
9398
Damn you vendor prefixes!
9499
</blockquote>
95100

96-
<p> What it currently looks like a lot more complex. Mozilla has created a very useful script that you can use to toggle full screen. As you can see, due to the vendor prefix situation it is rather complex and cumbersome compared to the specified API. Even with a slight smoother option, it is still complex. </p>
101+
<p> What it currently looks like a lot more complex. <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode">Mozilla has created</a> a very useful script that you can use to toggle full screen. As you can see, due to the vendor prefix situation it is rather complex and cumbersome compared to the specified API. Even with a slight smoother option, it is still complex. </p>
97102

98103
<pre class="prettyprint">function toggleFullScreen() {
99104
var doc = window.document;
@@ -110,7 +115,7 @@ <h3 id="toc-request">Requesting Full Screen</h3>
110115
}
111116
}</pre>
112117

113-
<p>We web developers hate complexity. A nice high-level abstract API you can use is Sindre Sorhus’ (http://sindresorhus.com/screenfull.js/) “Screenfull.js (https://github.com/sindresorhus/screenfull.js)” module which unifies the two slightly different JS APIs and vendor prefixes into one consistent API.</p>
118+
<p>We web developers hate complexity. A nice high-level abstract API you can use is <a href="http://sindresorhus.com/screenfull.js"/>Sindre Sorhus'</a> "<a href="https://github.com/sindresorhus/screenfull.js">Screenfull.js</a> module which unifies the two slightly different JS API's and vendor prefixes into one consistent API.</p>
114119

115120
<h3 id="toc-launch">Launching a page Full Screen</h3>
116121

@@ -123,7 +128,7 @@ <h4>iOS</h4>
123128

124129
<pre class="prettyprint">&lt;meta name="apple-mobile-web-app-capable" content="yes"></pre>
125130

126-
<p><a href="https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html">Apple</a>:</p>
131+
<p><a href="https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html">From Apple</a>:</p>
127132
<blockquote>If content is set to yes, the web application runs in full-screen mode; otherwise, it does not. The default behavior is to use Safari to display web content.
128133
You can determine whether a webpage is displayed in full-screen mode using the window.navigator.standalone read-only Boolean JavaScript property.
129134
</blockquote>
@@ -133,14 +138,14 @@ <h4>Chrome for Android</h4>
133138

134139
<pre class="prettyprint">&lt;meta name="mobile-web-app-capable" content="yes"></pre>
135140

136-
<p><a href="https://developers.google.com/chrome/mobile/docs/installtohomescreen">Chrome</a>:</p>
141+
<p><a href="https://developers.google.com/chrome/mobile/docs/installtohomescreen">From Chrome</a>:</p>
137142
<blockquote>You can set up your web app to have an application shortcut icon added to a device's homescreen, and have the app launch in full-screen "app mode" using Chrome for Android’s "Add to homescreen" menu item.</blockquote>
138143

139144
<h4>Firefox OS</h4>
140145
<p>Firefox OS has implemented a installable web app and packaged app model for developers to create apps for the user's phone. This model is a little more complex, but it fits in to a wider strategy of installable apps. The developer has to define a manifest for the app that Firefox OS will parse at install time.</p>
141146

142-
<p><a href="https://developer.mozilla.org/en-US/Apps/Developing/Manifest#fullscreen">Mozilla</a>:</p>
143-
<pre>{
147+
<p><a href="https://developer.mozilla.org/en-US/Apps/Developing/Manifest#fullscreen">From Mozilla</a>:</p>
148+
<pre class="prettyprint">{
144149
"name": "My App",
145150
"description": "My elevator pitch goes here",
146151
"launch_path": "/",
@@ -150,7 +155,7 @@ <h4>Firefox OS</h4>
150155
<b>"fullscreen": true</b>
151156
}</pre>
152157

153-
<h2 id="toc-useful">Useful interactions</h2>
158+
<h2 id="toc-useful">Interaction Guidelines</h2>
154159
<h3 id="toc-dontrely">Don’t rely on navigation controls</h3>
155160
<p>iOS and Firefox OS don’t every device has a hardware back button, you must ensure that users can navigate to their previous state. There is also no refresh gesture that is directly accessible.</p>
156161

@@ -184,10 +189,10 @@ <h4>Firefox</h4>
184189

185190
<h3 id="toc-keepuserin">Keep the user in the full screen experience</h3>
186191

187-
<p>The full screen API can be a little finicky sometimes, browsers don’t want to lock users in a full screen page so they will break out of full screen as soon as they possibly can. This means you cant build a full screen website that spans multiple pages because:</p>
192+
<p>The full screen API can be a little finicky sometimes, browsers don’t want to lock users in a full screen page so they will break out of full screen as soon as they possibly can. This means you can't build a full screen website that spans multiple pages because:</p>
188193

189194
<ul>
190-
<li>Changing the URL programmatically by using window.location = http://example.com breaks out of full screen</li>
195+
<li>Changing the URL programmatically by using window.location = "http://example.com" breaks out of full screen</li>
191196
<li>A user clicking on an external link inside your page will exit full screen</li>
192197
<li>Changing the URL via the navigator.pushState API will also break out of the full screen experience.</li>
193198
</ul>
@@ -199,12 +204,12 @@ <h3 id="toc-keepuserin">Keep the user in the full screen experience</h3>
199204
<li>Manage your UI and app state using the # fragment.</li>
200205
</ol>
201206

202-
<p>By using the #syntax to update the url (window.location = #somestate), and listening to the window.onhashchange event you can use the browser's own history stack to manage changes in the application state, allow the user to use their hardware back buttons, or offer a simple programmatic back button experience by using the history API - window.history.go(-1)</p>
207+
<p>By using the #syntax to update the url (window.location = "#somestate"), and listening to the window.onhashchange event you can use the browser's own history stack to manage changes in the application state, allow the user to use their hardware back buttons, or offer a simple programmatic back button experience by using the history API - window.history.go(-1)</p>
203208

204209
<h3 id="toc-letuserchoose">Let the user choose when to go full screen</h3>
205210
<p>There is nothing more annoying to the user on the web than doing what they don’t expect. When a user is navigating the your site don’t try and trick them into fullscreen.</p>
206211

207-
<p>Dont intercept the first touch event and issue a requestFullScreen.</p>
212+
<p>Don't intercept the first touch event and issue a requestFullScreen.</p>
208213
<ol>
209214
<li>it is annoying</li>
210215
<li>Browsers may decided to prompt the user at some point in the future about allowing the app to take up the full screen.</li>
@@ -213,7 +218,7 @@ <h3 id="toc-letuserchoose">Let the user choose when to go full screen</h3>
213218
<p>If you want to launch apps full screen do think about using the install experiences for each platform.</p>
214219

215220
<h3 id="toc-nospam">Don't spam the user to install your app to a homescreen</h3>
216-
<p>If you plan on offering a full screen experience via the installed app mechanisms, then just because you have the ability to detect if a users app is not running as an installed app does not mean the user wants to install your app all the time. </p>
221+
<p>If you plan on offering a full screen experience via the installed app mechanisms, then just because you have the ability to detect if a user's app is not running as an installed app does not mean the user wants to install your app all the time. </p>
217222

218223
<h3 id="toc-documentfullscreen">Making the document full screen</h3>
219224
<p>It is natural to think that you take the body element full screen, but if you are on a WebKit or Blink based rendering engine you will see it has an odd effect of shrinking the body width to the smallest possible size that will contain all the content (Mozilla Gecko is fine). This, more than likely is not what you want.</p>
@@ -223,34 +228,34 @@ <h3 id="toc-documentfullscreen">Making the document full screen</h3>
223228
<h3 id="toc-videofullscreen">Making a video element full screen</h3>
224229
<p>To make a video element fullscreen it is exactly the same as making any other element full screen. You call the `requestFullScreen` method on the video element.</p>
225230
<pre class="prettyprint">&lt;video id=videoElement>&lt;/video>
226-
&lt;button id=goFS>Go Fullscreen&lt;/button>
231+
&lt;button id="goFS">Go Fullscreen&lt;/button>
227232
&lt;script>
228-
var goFS = document.getElementById(goFS);
229-
goFS.addEventListener(click, function() {
230-
var videoElement = document.getElementById(videoElement);
233+
var goFS = document.getElementById("goFS");
234+
goFS.addEventListener("click", function() {
235+
var videoElement = document.getElementById("videoElement");
231236
videoElement.requestFullScreen();
232237
}, false);
233238
&lt;/script></pre>
234239

235240
<p>If your &lt;video&gt; element does not have the controls attribute defined, there will be no way for the user to control the video once they are full screen. The recommended way to do this is to have a basic container that wraps the video and the controls that you want the user to see.</p>
236241

237-
<pre class="prettyprint">&lt;div id=container>
242+
<pre class="prettyprint">&lt;div id="container">
238243
&lt;video>&lt;video>
239244
&lt;div>
240245
&lt;button>Play&lt;button>
241246
&lt;button>Stop&lt;button>
242-
&lt;button id=goFS>Go full screen&lt;button>
247+
&lt;button id="goFS">Go full screen&lt;button>
243248
&lt;div>
244249
&lt;div>
245250
&lt;script>
246-
var goFS = document.getElementById(goFS);
247-
goFS.addEventListener(click, function() {
248-
var container = document.getElementById(container);
251+
var goFS = document.getElementById("goFS");
252+
goFS.addEventListener("click", function() {
253+
var container = document.getElementById("container");
249254
container.requestFullScreen();
250255
}, false);
251256
&lt;script></pre>
252257

253-
<p>This actually gives you a lot more flexibility because you can combine the container object with the CSS pseudo selector (for example to hide the goFS button.)</p>
258+
<p>This actually gives you a lot more flexibility because you can combine the container object with the CSS pseudo selector (for example to hide the "goFS" button.)</p>
254259

255260
<pre class="prettyprint">&lt;style>
256261
#goFS::full-screen #goFS {
@@ -265,9 +270,8 @@ <h3 id="toc-videofullscreen">Making a video element full screen</h3>
265270
&lt;style></pre>
266271

267272
<h2 id="conslusions">Conclusions</h2>
268-
<p>Whilst we dont have a full standardised and implemented API, using some of the guidance presented in this article you can easily build experiences that take advantage of the users entire screen irrespective of the client.</p>
273+
<p>Whilst we don't have a full standardised and implemented API, using some of the guidance presented in this article you can easily build experiences that take advantage of the users entire screen irrespective of the client.</p>
269274

270275
<p>If you know of any good patterns for full-screen, leave a comment and we can let the world know. If you know of anti-patterns in full-screen let us know so we can update the article to save the frustrations of millions of users on the web. </p>
271276

272-
273277
{% endblock %}

0 commit comments

Comments
 (0)