Content-Length: 302319 | pFad | http://github.com/roeib/JavaScript-snippets/commit/b2d0d5e7cef104535d7d087dd4a0ba2c1105a5b5

83 get device orientation · roeib/JavaScript-snippets@b2d0d5e · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/roeib/JavaScript-snippets/commit/b2d0d5e7cef104535d7d087dd4a0ba2c1105a5b5

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy