MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 378147 of DeviceProximityEvent

  • Revision slug: DOM/DeviceProximityEvent
  • Revision title: DeviceProximityEvent
  • Revision id: 378147
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment

Revision Content

{{DomRef}}

Summary

The DeviceProximityEvent provides information about the distance of a nearby physical object using the proximity sensor of a device.

Properties

{{domxref("DeviceProximityEvent.max")}} {{readonlyinline}}
The maximum sensing distance the sensor is able to report, in centimeters.
{{domxref("DeviceProximityEvent.min")}} {{readonlyinline}}
The minimum sensing distance the sensor is able to report, in centimeters. Ususally zero.
{{domxref("DeviceProximityEvent.value")}} {{readonlyinline}}
The current device proximity, in centimeters.

Examples

window.addEventListener('deviceproximity', function(event) {
  console.log("value: " + event.value, "max: " + event.max, "min: " + event.min);
});

Specifications

Specification Status Comment
{{ SpecName('Proximity Events', '', 'Proximity Events') }} {{ Spec2('Proximity Events') }} Initial specification

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatNo() }} {{ CompatVersionUnknown() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatNo() }} {{ CompatNo() }} {{ CompatGeckoMobile("15.0") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}

See also

  • {{event("deviceproximity")}}
  • {{domxref("UserProximityEvent")}}
  • Proximity API

Revision Source

<p>{{DomRef}}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>DeviceProximityEvent</code> provides information about the distance of a nearby physical object using the proximity sensor of a device.</p>
<h2 id="Properties">Properties</h2>
<dl>
  <dt>
    {{domxref("DeviceProximityEvent.max")}} {{readonlyinline}}</dt>
  <dd>
    The maximum sensing distance the sensor is able to report, in centimeters.</dd>
  <dt>
    {{domxref("DeviceProximityEvent.min")}} {{readonlyinline}}</dt>
  <dd>
    The minimum sensing distance the sensor is able to report, in centimeters. Ususally zero.</dd>
  <dt>
    {{domxref("DeviceProximityEvent.value")}} {{readonlyinline}}</dt>
  <dd>
    The current device proximity, in centimeters.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre class="brush: js">
window.addEventListener('deviceproximity', function(event) {
&nbsp; console.log(<code class="brush: js">"value: " + event.value, "max: " + event.max, "min: " + event.min</code>);
});</pre>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table" height="49" width="1000">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ SpecName('Proximity Events', '', 'Proximity Events') }}</td>
      <td>{{ Spec2('Proximity Events') }}</td>
      <td>Initial specification</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatVersionUnknown() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Chrome for Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatGeckoMobile("15.0") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{event("deviceproximity")}}</li>
  <li>{{domxref("UserProximityEvent")}}</li>
  <li><a href="/en-US/docs/WebAPI/Proximity" title="/en-US/docs/WebAPI/Proximity">Proximity API</a></li>
</ul>
Revert to this revision