Skip to content

Repository files navigation

Screen Orientation Test

Codacy BadgeQuality Gate StatusBugsCode SmellsDuplicated Lines (%)Reliability RatingSecurity RatingTechnical DebtMaintainability RatingVulnerabilitiesCodacy Security ScanTestsDeploy Hugo site to PagesLines of CodeGitHub

This project builds a web page for testing user's browser if it can report active device screen orientation, and if it's possible to change and lock the screen orientation programmatically with JS. It's useful if you need to check if your iPhone or Android device supports this functionality and if you can use it in your web projects.

DEMO IS HERE

Cover image

How to test

  1. Open the demo page
  2. Rotate your device in the hands, the page should detect screen orientation change and display current state
  3. Try to change the screen orientation programmatically by clicking the buttons with the desired screen orientation. Please note that your device may support only some orientation types. Probably it will not work if you're not in fullscreen mode.
  4. Try clicking the fullscreen mode button. Most modern browsers require fullscreen mode activated to allow rotations.
  5. Try different browsers. The results can vary a lot.
  6. Install the website as an app (PWA) and try the previous steps.

Sample videos

Example 1. Android 10 Chrome browser 111.0.5563.116

Supports orientation detection, full-screen mode activation and programmatically change and lock of screen orientation.

android-chrome-111.0.5563.115_x265_002.mp4

Example 2. Android 10, PWA mode, Chrome browser 111.0.0.0

Supports orientation detection, full-screen mode activation and programmatically change and lock of screen orientation.

android-pwa_x265_001.mp4

Example 3. Android 10 DuckDuckGo 5.153.0

Supports orientation detection, full-screen mode activation. Programmatically change and lock of screen orientation is not supported.

DuckDuckGo-5.153.0_x265.mp4

Some test results

BrowserOSTypeModeDetectionFullscreen ModeRotation
Google Chrome 111.0.5563.116Android 7,10,12MobileBrowser
Google Chrome 111.0.0.0Android 7,10,12MobilePWA
Google Chrome 111.0.5563.147Windows 11DesktopBrowser
Firefox 111.1.0Android 7MobileBrowser
Brave 1.49.129Android 7MobileBrowser
DuckDuckGo 5.153.0Android 10, 12MobileBrowser
Yandex Browser 23.30.1Android 12MobileBrowser
Safari 15.6.4iOS 15.7.3, 15.7.4MobileBrowser
Safari 16.3iOS 13.2.1 VenturaDesktopBrowser
Safari 16.4iOS 13.3 VenturaDesktopBrowser

If you want to share your test results, please open an issue or PR.

Technical details

We use two methods to get screen lock:

Some devices like desktop computers usually don't support screen rotation. If a device does not support rotation, you will get such a message. However, such a message may be seen on mobile devices too if the browser does have a full support for the screen rotation API.

Usually, the screen rotation lock requires the fullscreen mode first to be activated in browser. There's a button to enter and exit fullscreen mode in the demo using Element.requestFullscreen().
Fullscreen mode is supported by most modern browsers.

The website is built with Hugo.

About

Tests for programmatically getting and locking screen orientation with JS

Topics

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Sponsor this project

Used by

Contributors

Languages