IdleDetector Class
Observes the idle state of the user and of the screen (https://wicg.github.io/idle-detection/#api-idledetector), read from the IdleStateProvider of the browsing context (IdleDetectionOptions.Provider): the change event is fired when the state changes, once the detector is started.
public sealed class IdleDetector : EventTarget- Inheritance
EventTargetIdleDetector
Constructors
| Name | Description |
|---|---|
| IdleDetector() | Creates a detector for the current global object (https://wicg.github.io/idle-detection/#api-idledetector). |
| IdleDetector(GlobalScope) | Creates a detector for a global object. |
IdleDetector overloads
IdleDetector()
IdleDetection.csCreates a detector for the current global object (https://wicg.github.io/idle-detection/#api-idledetector).
public IdleDetector()IdleDetector(GlobalScope)
IdleDetection.csCreates a detector for a global object.
public IdleDetector(GlobalScope global)Parameters
globalGlobalScope- The window or the dedicated worker whose detector it is.
Properties
| Name | Description |
|---|---|
| OnChange | Gets or sets the event handler of the change event. |
| ScreenState | Gets the last known idle state of the screen, or null before the detector is started. |
| UserState | Gets the last known idle state of the user, or null before the detector is started. |
OnChange
IdleDetection.csGets or sets the event handler of the change event.
Property value
See also
ScreenState
IdleDetection.csGets the last known idle state of the screen, or null before the detector is started.
public ScreenIdleState? ScreenState { get; }Property value
See also
UserState
IdleDetection.csGets the last known idle state of the user, or null before the detector is started.
public UserIdleState? UserState { get; }Property value
See also
Methods
| Name | Description |
|---|---|
| RequestPermission() | Asks the user to allow the origin to detect the idle state (https://wicg.github.io/idle-detection/#api-idledetector-requestpermission), with BrowsingContextOptions.RequestPermission, unless the permission is already granted or denied. The task fails with an InvalidStateError DomException when the document is not fully active, and with a NotAllowedError when the window has no transient activation. |
| Start(IdleOptions?) | Starts the detector (https://wicg.github.io/idle-detection/#api-idledetector-start): the change event is fired with the initial state, then at each change. The task fails with an InvalidStateError DomException when the document is not fully active or the detector is already started, a NotAllowedError when the document is not allowed to use the idle-detection feature or the idle-detection permission is denied, a TypeErrorException when the threshold is less than 60 seconds, and the abort reason of the signal when it is aborted. |
RequestPermission()
IdleDetection.csAsks the user to allow the origin to detect the idle state (https://wicg.github.io/idle-detection/#api-idledetector-requestpermission), with BrowsingContextOptions.RequestPermission, unless the permission is already granted or denied. The task fails with an InvalidStateError DomException when the document is not fully active, and with a NotAllowedError when the window has no transient activation.
public static Task<PermissionState> RequestPermission()Start(IdleOptions?)
IdleDetection.csStarts the detector (https://wicg.github.io/idle-detection/#api-idledetector-start): the change event is fired with the initial state, then at each change. The task fails with an InvalidStateError DomException when the document is not fully active or the detector is already started, a NotAllowedError when the document is not allowed to use the idle-detection feature or the idle-detection permission is denied, a TypeErrorException when the threshold is less than 60 seconds, and the abort reason of the signal when it is aborted.
public Task Start(IdleOptions? options = null)