DeviceMotionEvent Class

The devicemotion event of a window (https://w3c.github.io/deviceorientation/#devicemotion): the acceleration (linear acceleration sensor) and the acceleration including the gravity (accelerometer) in m/s² rounded to 0.1 m/s², and the rotation rate (gyroscope) in deg/s rounded to 0.1 deg/s, read from the DeviceSensorProvider of the browsing context. It is fired when a listener is added and every 16 ms while the sensors get new readings, while the document is visible.

public sealed class DeviceMotionEvent : Event
Inheritance
Event DeviceMotionEvent

Constructors

NameDescription
DeviceMotionEvent(string, DeviceMotionEventInit?)Creates a device motion event.

DeviceMotionEvent(string, DeviceMotionEventInit?)

DeviceOrientationEvents.cs

Creates a device motion event.

public DeviceMotionEvent(string type, DeviceMotionEventInit? eventInitDict = null)

Properties

NameDescription
AccelerationGets the acceleration of the device without the gravity, or null.
AccelerationIncludingGravityGets the acceleration of the device including the gravity, or null.
IntervalGets the interval at which the data is obtained, in milliseconds.
RotationRateGets the rotation rate of the device, or null.

Gets the acceleration of the device without the gravity, or null.

public DeviceMotionEventAcceleration? Acceleration { get; }

AccelerationIncludingGravity

DeviceOrientationEvents.cs

Gets the acceleration of the device including the gravity, or null.

public DeviceMotionEventAcceleration? AccelerationIncludingGravity { get; }

Gets the interval at which the data is obtained, in milliseconds.

public double Interval { get; }

Gets the rotation rate of the device, or null.

public DeviceMotionEventRotationRate? RotationRate { get; }

Methods

NameDescription
RequestPermission()Requests the permissions of the motion events (https://w3c.github.io/deviceorientation/#dom-devicemotionevent-requestpermission): accelerometer and gyroscope. The task fails with a NotAllowedError DomException when a permission would prompt the user without a transient activation.

RequestPermission()

DeviceOrientationEvents.cs

Requests the permissions of the motion events (https://w3c.github.io/deviceorientation/#dom-devicemotionevent-requestpermission): accelerometer and gyroscope. The task fails with a NotAllowedError DomException when a permission would prompt the user without a transient activation.

public static Task<PermissionState> RequestPermission()