aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/orphaned
diff options
context:
space:
mode:
authorMDN <actions@users.noreply.github.com>2021-06-20 00:37:04 +0000
committerMDN <actions@users.noreply.github.com>2021-06-20 00:37:04 +0000
commit0d495ad297d9e90ab35f54a822cd5e4e6a670713 (patch)
tree399dbe0b28db6d16fe7d13444e41b89e02e5ddc6 /files/zh-cn/orphaned
parentbccf9a19dac45b167f5ea1a427fb682a78b48187 (diff)
downloadtranslated-content-0d495ad297d9e90ab35f54a822cd5e4e6a670713.tar.gz
translated-content-0d495ad297d9e90ab35f54a822cd5e4e6a670713.tar.bz2
translated-content-0d495ad297d9e90ab35f54a822cd5e4e6a670713.zip
[CRON] sync translated content
Diffstat (limited to 'files/zh-cn/orphaned')
-rw-r--r--files/zh-cn/orphaned/web/api/ambient_light_events/index.html75
-rw-r--r--files/zh-cn/orphaned/web/api/devicelightevent/index.html62
2 files changed, 137 insertions, 0 deletions
diff --git a/files/zh-cn/orphaned/web/api/ambient_light_events/index.html b/files/zh-cn/orphaned/web/api/ambient_light_events/index.html
new file mode 100644
index 0000000000..79a7ed9fbe
--- /dev/null
+++ b/files/zh-cn/orphaned/web/api/ambient_light_events/index.html
@@ -0,0 +1,75 @@
+---
+title: Using Light Events
+slug: orphaned/Web/API/Ambient_Light_Events
+tags:
+ - WebAPI
+ - 事件
+ - 环境光
+translation_of: Web/API/Ambient_Light_Events
+original_slug: Web/API/Ambient_Light_Events
+---
+<div>{{DefaultAPISidebar("Ambient Light Events")}}{{SeeCompatTable}}</div>
+
+<p>环境光线事件是一个易用的让网页或应用感知光强变化的方法。它使网页或应用能对光强变化做出反应,例如改变用户界面的颜色对比度,或为拍照而改变曝光度。</p>
+
+<h2 id="光线事件">光线事件</h2>
+
+<p>当设备的光线传感器检测到光强等级的变化时,它会向浏览器通知这个变化。当浏览器得到这个通知后,会发送(fire)一个提供光强信息的 {{domxref("DeviceLightEvent")}} 事件。</p>
+
+<p>想要捕获这个事件,可用 {{domxref("EventTarget.addEventListener","addEventListener")}} 方法把事件处理器绑定到 <code>window</code> 上(使用 {{event("devicelight")}} 事件名),或者直接把事件处理器赋值给 {{domxref("window.ondevicelight")}} 属性。</p>
+
+<p>该事件被捕捉后,可以从传入的事件对象上的 {{domxref("DeviceLightEvent.value")}} 属性获取光强(单位为 {{interwiki("wikipedia", "lux")}})。</p>
+
+<h2 id="示例">示例</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 事件');
+}
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{ SpecName('AmbientLight', '', 'Ambient Light Events') }}</td>
+ <td>{{ Spec2('AmbientLight') }}</td>
+ <td>首次定义</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.DeviceLightEvent")}}</p>
+
+<h3 id="Gecko_备注">Gecko 备注</h3>
+
+<p>{{event("devicelight")}} 事件在 Firefox Mobile for Android (15.0) 和 Firefox OS (B2G) 上实现并默认可用。从Gecko 22.0 {{geckoRelease("22.0")}} 开始,Mac OS X桌面版也可使用该事件。</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{domxref("DeviceLightEvent")}}</li>
+ <li>{{event("devicelight")}}</li>
+</ul>
diff --git a/files/zh-cn/orphaned/web/api/devicelightevent/index.html b/files/zh-cn/orphaned/web/api/devicelightevent/index.html
new file mode 100644
index 0000000000..e3e717c514
--- /dev/null
+++ b/files/zh-cn/orphaned/web/api/devicelightevent/index.html
@@ -0,0 +1,62 @@
+---
+title: DeviceLightEvent
+slug: orphaned/Web/API/DeviceLightEvent
+tags:
+ - API
+ - Ambient Light Events
+ - Experimental
+ - Interface
+ - NeedsBetterSpecLink
+ - NeedsMarkupWork
+ - 事件
+translation_of: Web/API/DeviceLightEvent
+original_slug: Web/API/DeviceLightEvent
+---
+<div>{{apiref("Ambient Light Events")}}{{SeeCompatTable}}</div>
+
+<p><code>DeviceLightEvent</code> 为 Web 开发人员提供来自光传感器或类似设备的、关于附近环境光水平的信息。例如,基于当前环境光水平调节屏幕的亮度,以便节省电量或提供更好的阅读性。</p>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt>{{domxref("DeviceLightEvent.value")}}</dt>
+ <dd>环境光的亮度,单位为 {{interwiki("wikipedia", "lux")}}。</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<pre class="brush: js">window.addEventListener('devicelight', function(event) {
+ console.log(event.value);
+});</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{ SpecName('AmbientLight', '', 'Ambient Light Events') }}</td>
+ <td>{{ Spec2('AmbientLight') }}</td>
+ <td>Initial specification</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.DeviceLightEvent")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{ event("devicelight") }}</li>
+ <li><a href="/zh-CN/docs/WebAPI/Using_Light_Events">使用环境光事件</a></li>
+</ul>