Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

get_orientation() and hence getScreenHeight() doesn't work on some devices #2933

Closed
@ghost

Description

This problem is reproducible only in the JQueryMobile 1.0RC2 release, and wasn't reproducible in beta 2.

On iPad 2 with iOS 5, I observe that window.orientation is -90 when in landscape mode. However on Thinkpad running Android 3.1, window.orientation is 0 when in landscape mode. When running Playbook OS 2, window.orientation is also 0 when in landscape mode. Because of this, jQuery.event.special.orientationchange.orientation() returns the wrong value on Android and Playbook but the right value on iPad.

It seems like using window.orientation to determine whether the device is in landscape or portrait is not a reliable way of doing it. Maybe it would be best to determine this by checking whether the windows dimensions are wider or taller?

Here is a test page that demonstrates this issue:

<html>
   <head>
      <link href="jquery.mobile.css" rel="stylesheet"></link>
      <script src="jquery-1.6.3.js"></script>
      <script src="jquery.mobile.js"></script>
      <script type="text/javascript">
         $(document).ready(function(){
            $('#text').text("Orientation is: " + jQuery.event.special.orientationchange.orientation() + ", window.orientation is " + window.orientation)

            $(window).bind('resize', function(){
               $('#text').text("Orientation is: " + jQuery.event.special.orientationchange.orientation() + ",     window.orientation is " + window.orientation)
            })
         })
      </script>
      <title>Test Orientation</title>
   </head>
   <body>
      <h1 id="text"></h1>
   </body>
</head>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions