I am developing a phone application and have a problem with the orientation of the device.
Basically, I want the user to have the right to use the device at his discretion, be it a portrait or a landscape. However, I want the screen to display only in Portrait or Landscape mode. Currently, the screen is also reversing the landscape.
Is it possible to limit orientation changes only to portrait and landscape? (so you’ll only have 2 options for changing orientation, not 3).
EDIT
I used the plugin (suggested below) and came up with the code below. As soon as the screen is rotated in reverseLandscape, it is displayed in landscape mode (exactly what I wanted). However, the problem is that if the user switches the mobile in portrait mode, the orientation is locked and will not return to the portrait.
$(window).bind('orientationchange', function(event){ if (event.orientation == 'landscape') { navigator.screenOrientation.set('landscape'); } if (event.orientation == 'portrait') { navigator.screenOrientation.set('portrait'); } });
Does anyone know where I should put the next line so that it unlocks the orientation?
navigator.screenOrientation.set('fullSensor');
jquery jquery-mobile cordova
user1809790
source share