ProximitySensor Class

The proximity sensor (https://w3c.github.io/proximity/#proximity-sensor-interface): the distance to the closest object, in cm. It reads the DeviceSensorType.Proximity sensor of the device, and needs the proximity permission and the proximity-sensor permissions policy feature.

public sealed class ProximitySensor : Sensor
Inheritance
Sensor ProximitySensor

Constructors

NameDescription
ProximitySensor(SensorOptions?)Creates a proximity sensor. Throws a SecurityError DomException when the document is not allowed to use the proximity-sensor feature.

ProximitySensor(SensorOptions?)

MotionSensors.cs

Creates a proximity sensor. Throws a SecurityError DomException when the document is not allowed to use the proximity-sensor feature.

public ProximitySensor(SensorOptions? sensorOptions = null)

Properties

NameDescription
DistanceGets the distance to the closest object, in cm, or null.
MaxGets the maximum sensing range, in cm, or null.
NearGets whether an object is near, or null.

Gets the distance to the closest object, in cm, or null.

public double? Distance { get; }

Gets the maximum sensing range, in cm, or null.

public double? Max { get; }

Gets whether an object is near, or null.

public bool? Near { get; }