aboutsummaryrefslogtreecommitdiff
path: root/files/pt-pt/web/api/ambient_light_events
diff options
context:
space:
mode:
authorFlorian Merz <me@fiji-flo.de>2021-02-11 14:50:24 +0100
committerFlorian Merz <me@fiji-flo.de>2021-02-11 14:50:24 +0100
commit2c2df5ea01eb5cd8b9ea226b2869337e59c5fe3e (patch)
tree86ab4534d10092b293d4b7ab169fe1a8a2421bfa /files/pt-pt/web/api/ambient_light_events
parent8260a606c143e6b55a467edf017a56bdcd6cba7e (diff)
downloadtranslated-content-2c2df5ea01eb5cd8b9ea226b2869337e59c5fe3e.tar.gz
translated-content-2c2df5ea01eb5cd8b9ea226b2869337e59c5fe3e.tar.bz2
translated-content-2c2df5ea01eb5cd8b9ea226b2869337e59c5fe3e.zip
unslug pt-pt: move
Diffstat (limited to 'files/pt-pt/web/api/ambient_light_events')
-rw-r--r--files/pt-pt/web/api/ambient_light_events/index.html70
1 files changed, 70 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..32b15a8ea1
--- /dev/null
+++ b/files/pt-pt/web/api/ambient_light_events/index.html
@@ -0,0 +1,70 @@
+---
+title: Eventos de Luz Ambiente
+slug: Web/API/Eventos_de_Luz_Ambiente
+tags:
+ - Luz Ambiente
+translation_of: Web/API/Ambient_Light_Events
+---
+<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>