-
Notifications
You must be signed in to change notification settings - Fork 22.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document UserActivation API (#21285)
- Loading branch information
Showing
9 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: Navigator.userActivation | ||
slug: Web/API/Navigator/userActivation | ||
page-type: web-api-instance-property | ||
tags: | ||
- API | ||
- Property | ||
- Reference | ||
browser-compat: api.Navigator.userActivation | ||
--- | ||
|
||
{{APIRef("HTML DOM")}} {{SeeCompatTable}} | ||
|
||
The read-only **`userActivation`** property of the {{domxref("Navigator")}} interface returns a {{domxref("UserActivation")}} object which contains information about the current window's user activation state. | ||
|
||
## Value | ||
|
||
A {{domxref("UserActivation")}} object. | ||
|
||
## Examples | ||
|
||
### Checking if a user gesture was recently performed | ||
|
||
Use {{domxref("UserActivation.isActive")}} to check wether the user is currently interacting with the page ({{Glossary("Transient activation")}}). | ||
|
||
```js | ||
if (navigator.userActivation.isActive) { | ||
// proceed to request playing media, for example | ||
} | ||
``` | ||
|
||
### Checking if a user gesture was ever performed | ||
|
||
Use {{domxref("UserActivation.hasBeenActive")}} to check wether the user has ever interacted with the page ({{Glossary("Sticky activation")}}). | ||
|
||
```js | ||
if (navigator.userActivation.hasBeenActive) { | ||
// proceed with auto-playing an animation, for example | ||
} | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("UserActivation")}} | ||
- {{domxref("UserActivation.hasBeenActive")}} | ||
- {{domxref("UserActivation.isActive")}} | ||
- [Features gated by user activation](/en-US/docs/Web/Security/User_activation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
title: UserActivation.hasBeenActive | ||
slug: Web/API/UserActivation/hasBeenActive | ||
page-type: web-api-instance-property | ||
tags: | ||
- API | ||
- Property | ||
- Reference | ||
browser-compat: api.UserActivation.hasBeenActive | ||
--- | ||
|
||
{{APIRef("HTML DOM")}} {{SeeCompatTable}} | ||
|
||
The read-only **`hasBeenActive`** property of the {{domxref("UserActivation")}} interface indicates whether the current window has sticky user activation (see {{Glossary("sticky activation")}}). | ||
|
||
## Value | ||
|
||
A boolean. | ||
|
||
## Examples | ||
|
||
### Checking if a user gesture was ever performed | ||
|
||
Use the `hasBeenActive` property to check wether the user has ever interacted with the page. | ||
|
||
```js | ||
if (navigator.userActivation.hasBeenActive) { | ||
// proceed with auto-playing an animation, for example | ||
} | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("UserActivation")}} | ||
- {{domxref("UserActivation.isActive")}} | ||
- [Features gated by user activation](/en-US/docs/Web/Security/User_activation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
title: UserActivation | ||
slug: Web/API/UserActivation | ||
page-type: web-api-interface | ||
tags: | ||
- API | ||
- Interface | ||
- Reference | ||
browser-compat: api.UserActivation | ||
--- | ||
|
||
{{APIRef("HTML DOM")}}{{SeeCompatTable}} | ||
|
||
The **`UserActivation`** interface allows querying information about a window's user activation state. | ||
|
||
A user activation either implies that the user is currently interacting with the page, or has completed an interaction since page load. Typically, this is a click on a button or some other user interaction with the UI. | ||
|
||
There are two kinds of window user activation states: | ||
|
||
- {{Glossary("Transient activation")}} (user is currently interacting with the page) and | ||
- {{Glossary("Sticky activation")}} (user has interacted at least once since page load). | ||
|
||
See [Features gated by user activation](/en-US/docs/Web/Security/User_activation) for more information and a list of APIs that require either sticky or transient user activation. | ||
|
||
This API is only available in the window context and not exposed to workers. | ||
|
||
## Properties | ||
|
||
- {{domxref("UserActivation.hasBeenActive")}} {{ReadOnlyInline}} {{experimental_inline}} | ||
- : Indicates whether the current window has sticky user activation. | ||
- {{domxref("UserActivation.isActive")}} {{ReadOnlyInline}} {{experimental_inline}} | ||
- : Indicates whether the current window has transient user activation. | ||
|
||
## Examples | ||
|
||
### Checking if a user gesture was recently performed | ||
|
||
Use {{domxref("UserActivation.isActive")}} to check wether the user is currently interacting with the page ({{Glossary("Transient activation")}}). | ||
|
||
```js | ||
if (navigator.userActivation.isActive) { | ||
// proceed to request playing media, for example | ||
} | ||
``` | ||
|
||
### Checking if a user gesture was ever performed | ||
|
||
Use {{domxref("UserActivation.hasBeenActive")}} to check wether the user has ever interacted with the page ({{Glossary("Sticky activation")}}). | ||
|
||
```js | ||
if (navigator.userActivation.hasBeenActive) { | ||
// proceed with auto-playing an animation, for example | ||
} | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("navigator.userActivation")}} | ||
- [Features gated by user activation](/en-US/docs/Web/Security/User_activation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
title: UserActivation.isActive | ||
slug: Web/API/UserActivation/isActive | ||
page-type: web-api-instance-property | ||
tags: | ||
- API | ||
- Property | ||
- Reference | ||
browser-compat: api.UserActivation.isActive | ||
--- | ||
|
||
{{APIRef("HTML DOM")}} {{SeeCompatTable}} | ||
|
||
The read-only **`isActive`** property of the {{domxref("UserActivation")}} interface indicates whether the current window has transient user activation (see {{Glossary("transient activation")}}). | ||
|
||
## Value | ||
|
||
A boolean. | ||
|
||
## Examples | ||
|
||
### Checking if a user gesture was recently performed | ||
|
||
Use the `isActive` property to check wether the user is currently interacting with the page. | ||
|
||
```js | ||
if (navigator.userActivation.isActive) { | ||
// proceed to request playing media, for example | ||
} | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{domxref("UserActivation")}} | ||
- {{domxref("UserActivation.hasBeenActive")}} | ||
- [Features gated by user activation](/en-US/docs/Web/Security/User_activation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters