-
Notifications
You must be signed in to change notification settings - Fork 22.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
2 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
45 changes: 45 additions & 0 deletions
45
files/en-us/web/api/screenorientation/change_event/index.md
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,45 @@ | ||
--- | ||
title: "ScreenOrientation: change event" | ||
short-title: change | ||
slug: Web/API/ScreenOrientation/change_event | ||
page-type: web-api-event | ||
browser-compat: api.ScreenOrientation.change_event | ||
--- | ||
|
||
{{securecontext_header}}{{APIRef("Idle Detection API")}}{{SeeCompatTable}} | ||
|
||
The **`change`** event of the {{domxref("ScreenOrientation")}} fires when the orientation of the screen has changed, for example when a user rotates his mobile phone. | ||
|
||
## Syntax | ||
|
||
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property. | ||
|
||
```js | ||
addEventListener("change", (event) => {}); | ||
|
||
onchange = (event) => {}; | ||
``` | ||
|
||
## Event type | ||
|
||
A generic {{domxref("Event")}}. | ||
|
||
## Example | ||
|
||
In the following example, the `change` callback prints the status of `userState` and `screenState` to the console. | ||
|
||
```js | ||
screen.orientation.addEventListener("change", (event) => { | ||
const type = event.target.type; | ||
const angle = event.target.angle; | ||
console.log(`ScreenOrientation change: ${type}, ${angle} degrees.`); | ||
}); | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} |
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