aboutsummaryrefslogtreecommitdiff
path: root/files/pt-pt/web/api/ambient_light_events/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/pt-pt/web/api/ambient_light_events/index.html')
-rw-r--r--files/pt-pt/web/api/ambient_light_events/index.html71
1 files changed, 71 insertions, 0 deletions
diff --git a/files/pt-pt/web/api/ambient_light_events/index.html b/files/pt-pt/web/api/ambient_light_events/index.html
new file mode 100644
index 0000000000..0605b2098a
--- /dev/null
+++ b/files/pt-pt/web/api/ambient_light_events/index.html
@@ -0,0 +1,71 @@
+---
+title: Eventos de Luz Ambiente
+slug: Web/API/Ambient_Light_Events
+tags:
+ - Luz Ambiente
+translation_of: Web/API/Ambient_Light_Events
+original_slug: Web/API/Eventos_de_Luz_Ambiente
+---
+<div>{{DefaultAPISidebar("Ambient Light Events")}}{{SeeCompatTable}}</div>
+
+<p>Os eventos de luz ambiente são uma maneira prática de tornar uma página da Web ou um aplicação ciente de qualquer alteração na intensidade da luz. Isto permite-lhes reagir a essa alteração, por exemplo, alterando o contraste da cor da interface do utilizador (IU) ou alterando a exposição necessária para tirar uma fotografia.</p>
+
+<h2 id="Eventos_de_Luz">Eventos de Luz</h2>
+
+<p>When the light sensor of a device detects a change in the light level, it notifies the browser of that change. When the browser gets such a notification, it fires a {{domxref("DeviceLightEvent")}} event that provides information about the exact light intensity.</p>
+
+<p>This event can be captured at the <code>window</code> object level by using the {{domxref("EventTarget.addEventListener","addEventListener")}} method (using the {{event("devicelight")}} event name) or by attaching an event handler to the {{domxref("window.ondevicelight")}} property.</p>
+
+<p>Once captured, the event object gives access to the light intensity expressed in <a href="http://en.wikipedia.org/wiki/Lux">lux</a> through the {{domxref("DeviceLightEvent.value")}} property.</p>
+
+<h2 id="Exemplo">Exemplo</h2>
+
+<pre class="brush: js">if ('ondevicelight' in window) {
+ window.addEventListener('devicelight', function(event) {
+ var body = document.querySelector('body');
+ if (event.value &lt; 50) {
+ body.classList.add('darklight');
+ body.classList.remove('brightlight');
+ } else {
+ body.classList.add('brightlight');
+ body.classList.remove('darklight');
+ }
+ });
+} else {
+  console.log('devicelight event not supported');
+}
+</pre>
+
+<h2 id="Especificações">Especificações</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Especificação</th>
+ <th scope="col">Estado</th>
+ <th scope="col">Comentário</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("AmbientLight", "", "Ambient Light Events")}}</td>
+ <td>{{Spec2("AmbientLight")}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilidade_de_navegador">Compatibilidade de navegador</h2>
+
+
+
+<p>{{Compat("api.DeviceLightEvent")}}</p>
+
+<p> </p>
+
+<h2 id="Consultar_também">Consultar também</h2>
+
+<ul>
+ <li>{{domxref("DeviceLightEvent")}}</li>
+ <li>{{event("devicelight")}}</li>
+</ul>