DeviceOrientationEvent Class

The deviceorientation and deviceorientationabsolute events of a window (https://w3c.github.io/deviceorientation/#deviceorientation): the orientation of the device as intrinsic Tait-Bryan angles Z - X' - Y'' in degrees, rounded to 0.1 degree. They are fired when a listener is added and when the orientation sensor of the DeviceSensorProvider of the browsing context gets a new reading, while the document is visible.

public sealed class DeviceOrientationEvent : Event
Inheritance
Event DeviceOrientationEvent

Constructors

NameDescription
DeviceOrientationEvent(string, DeviceOrientationEventInit?)Creates a device orientation event.

DeviceOrientationEvent(string, DeviceOrientationEventInit?)

DeviceOrientationEvents.cs

Creates a device orientation event.

public DeviceOrientationEvent(string type, DeviceOrientationEventInit? eventInitDict = null)

Properties

NameDescription
AbsoluteGets whether the orientation is relative to the Earth.
AlphaGets the rotation around the Z axis, in degrees, or null.
BetaGets the rotation around the X' axis, in degrees, or null.
GammaGets the rotation around the Y'' axis, in degrees, or null.

Gets whether the orientation is relative to the Earth.

public bool Absolute { get; }

Gets the rotation around the Z axis, in degrees, or null.

public double? Alpha { get; }

Gets the rotation around the X' axis, in degrees, or null.

public double? Beta { get; }

Gets the rotation around the Y'' axis, in degrees, or null.

public double? Gamma { get; }

Methods

NameDescription
RequestPermission(bool)Requests the permissions of the orientation events (https://w3c.github.io/deviceorientation/#dom-deviceorientationevent-requestpermission): accelerometer and gyroscope, and magnetometer when absolute is true. The task fails with a NotAllowedError DomException when a permission would prompt the user without a transient activation.

RequestPermission(bool)

DeviceOrientationEvents.cs

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

public static Task<PermissionState> RequestPermission(bool absolute = false)

Parameters

absolute bool
Whether the absolute orientation is requested.

Returns

Task<PermissionState>

See also