Skip to content

Commit b2d0d5e

Browse files
authored
get device orientation
get device orientation
1 parent b34f9d1 commit b2d0d5e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
|43 | [toFixed](#toFixed)|
5050
|44 | [generate randomUUID](#generate-random-uuid)|
5151
|45 | [structuredClone](#structuredClone)|
52-
53-
54-
52+
|46 | [get device orientation](#get-device-orientation)|
5553

5654

5755
**[⬆ Back to Top](#table-of-contents)**
@@ -981,4 +979,18 @@ console.log("clonedUser.address.street:", clonedUser.address.street);
981979
// > New Road
982980
983981
982+
```
983+
984+
**[⬆ Back to Top](#table-of-contents)**
985+
### get device orientation
986+
987+
Browsers expose a global variable named screen, which we’ll use to access the information we need.
988+
989+
```javascript
990+
991+
function getOrientation() {
992+
const isPortrait = screen.orientation.type.startswith('portrait')
993+
return isPortrait ? 'portrait' : 'landscape'
994+
}
995+
984996
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy