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
EventDeviceMotionEvent
Constructors
| Name | Description |
|---|---|
| DeviceMotionEvent(string, DeviceMotionEventInit?) | Creates a device motion event. |
DeviceMotionEvent(string, DeviceMotionEventInit?)
DeviceOrientationEvents.csCreates a device motion event.
public DeviceMotionEvent(string type, DeviceMotionEventInit? eventInitDict = null)Properties
| Name | Description |
|---|---|
| Acceleration | Gets the acceleration of the device without the gravity, or null. |
| AccelerationIncludingGravity | Gets the acceleration of the device including the gravity, or null. |
| Interval | Gets the interval at which the data is obtained, in milliseconds. |
| RotationRate | Gets the rotation rate of the device, or null. |
Acceleration
DeviceOrientationEvents.csGets the acceleration of the device without the gravity, or null.
public DeviceMotionEventAcceleration? Acceleration { get; }AccelerationIncludingGravity
DeviceOrientationEvents.csGets the acceleration of the device including the gravity, or null.
public DeviceMotionEventAcceleration? AccelerationIncludingGravity { get; }Interval
DeviceOrientationEvents.csGets the interval at which the data is obtained, in milliseconds.
public double Interval { get; }RotationRate
DeviceOrientationEvents.csGets the rotation rate of the device, or null.
public DeviceMotionEventRotationRate? RotationRate { get; }Methods
| Name | Description |
|---|---|
| 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.csRequests 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()