Is there anyway to lock the orientation to Portrait when on an iPhone or Android?

0
0

I tried adding the following inside a <script> tag in default.html:

window.addEventListener('orientationchange', function () {
    if (window.orientation == -90) {
        document.getElementById('orient').className = 'orientright';
    }
    if (window.orientation == 90) {
        document.getElementById('orient').className = 'orientleft';
    }
    if (window.orientation == 0) {
        document.getElementById('orient').className = '';
    }
}, true);

and then added <style> tag to the <head>:

.orientleft #shell {
    -webkit-transform: rotate(-90deg);
    -webkit-transform-origin:160px 160px;
}

.orientright #shell {
    -webkit-transform: rotate(90deg);
    -webkit-transform-origin:230px 230px;
} 

But it didn't seem to work.

Is there anyway to do this?
  • You must to post comments
0
0

try this: https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation

but it’s limited to installed web apps and full screen.

 

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.