lmac34
lmac34

Reputation: 174

Device: force orientation landscape (Phonegap JQueryMobile)

I have been searching for days for a way to always display just one particular jquery mobile page div in landscape mode.

Anyone any examples or ideas that could help, I would really appreciate it.

function forceLandscape() {
    console.log('Starting: forceLandscape ');
    console.log('----------------------------------------------------');


    //    var orientation = window.orientation;
    //    var new_orientation = 0;
    //    switch (orientation) {
    //        case 90:
    //            break;
    //        case -90:
    //            new_orientation = 180
    //            $('body').css({ ".ui-mobile,.ui-mobile .ui-page{min-height:300px} -webkit-transform": "rotate(" + new_orientation + "deg);" });
    //            break;
    //        case 180:
    //            new_orientation = 270;
    //            $('body').css({ ".ui-mobile,.ui-mobile .ui-page{min-height:300px} -webkit-transform": "rotate(" + new_orientation + "deg);" });
    //            break;
    //        case 0:
    //            new_orientation = 90;
    //            $('body').css({ ".ui-mobile,.ui-mobile .ui-page{min-height:300px} -webkit-transform": "rotate(" + new_orientation + "deg);" });
    //            break;
    //        default:
    //            $('body').css({ ".ui-mobile,.ui-mobile .ui-page{min-height:300px} -webkit-transform": "rotate(" + new_orientation + "deg);" });
    //    }  


    console.log('----------------------------------------------------');
    console.log('Completed: forceLandscape ');
}

Upvotes: 3

Views: 5277

Answers (1)

codaniel
codaniel

Reputation: 5253

This isn't recommended but you could do:

$('body').css({
   "-webkit-transform": "rotate(90deg)"
   put other browsers here
}); 

or just in css

#page {
transform:rotate(90deg);
-ms-transform:rotate(90deg); /* IE 9 */
-moz-transform:rotate(90deg); /* Firefox */
-webkit-transform:rotate(90deg); /* Safari and Chrome */
-o-transform:rotate(90deg); /* Opera */
}

Upvotes: 1

Related Questions