ScreenOrientation Class
The orientation of the screen of a window (https://w3c.github.io/screen-orientation/#screenorientation-interface, screen.orientation), read from the ScreenOrientationProvider of the browsing context (ScreenOrientationOptions.Provider): its type and angle, its change event, and the orientation locks.
public sealed class ScreenOrientation : EventTarget- Inheritance
EventTargetScreenOrientation
Properties
| Name | Description |
|---|---|
| Angle | Gets the last known angle of the screen in degrees, from its natural orientation (the [[angle]] slot). |
| OnChange | Gets or sets the event handler of the change event. |
| Type | Gets the last known orientation of the screen (the [[type]] slot). |
Angle
ScreenOrientation.csGets the last known angle of the screen in degrees, from its natural orientation (the [[angle]] slot).
public ushort Angle { get; }OnChange
ScreenOrientation.csGets or sets the event handler of the change event.
Property value
See also
Gets the last known orientation of the screen (the [[type]] slot).
public OrientationType Type { get; }Property value
See also
Methods
| Name | Description |
|---|---|
| Lock(OrientationLockType) | Locks the orientation of the screen (https://w3c.github.io/screen-orientation/#lock-method), with the ScreenOrientationProvider of the browsing context. The task completes once the screen is locked, after the change event. It fails with an InvalidStateError DomException when the document is not fully active, a SecurityError when it is sandboxed without allow-orientation-lock or hidden, a NotSupportedError when the screen cannot be locked, a NotAllowedError when the top-level document is not fullscreen, and an AbortError when another lock request or ScreenOrientation.Unlock replaces it, or the document is unloaded. |
| Unlock() | Unlocks the orientation of the screen (https://w3c.github.io/screen-orientation/#unlock-method): the screen gets the orientation of the device back, and a pending lock request is aborted. |
Lock(OrientationLockType)
ScreenOrientation.csLocks the orientation of the screen (https://w3c.github.io/screen-orientation/#lock-method), with the ScreenOrientationProvider of the browsing context. The task completes once the screen is locked, after the change event. It fails with an InvalidStateError DomException when the document is not fully active, a SecurityError when it is sandboxed without allow-orientation-lock or hidden, a NotSupportedError when the screen cannot be locked, a NotAllowedError when the top-level document is not fullscreen, and an AbortError when another lock request or ScreenOrientation.Unlock replaces it, or the document is unloaded.
public Task Lock(OrientationLockType orientation)Unlock()
ScreenOrientation.csUnlocks the orientation of the screen (https://w3c.github.io/screen-orientation/#unlock-method): the screen gets the orientation of the device back, and a pending lock request is aborted.
public void Unlock()Exceptions
DomException- The document is not fully active (
InvalidStateError), or is sandboxed or hidden (SecurityError).