This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for issue #2933 - get_orientation() and hence getScreenHeight() d…
…oesn't work on some devices It seems that some device/browser vendors use window.orientation values 0 and 180 to denote the "default" orientation. For iOS devices, and most other smart-phones tested, the default orientation is always "portrait", but in some Android and RIM based tablets, the default orientation is "landscape". - Modified the orientationchange plugin so that it injects a landscape orientation media query into the document to figure out what the initial orientation is, it then makes adjustments to a portrait_map if necessary, so that we can properly decode the window.orientation value whenever get_orientation() is called.
- Loading branch information
Showing
2 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>jQuery Mobile: Event Logger</title> | ||
<link rel="stylesheet" href="../../css/themes/default/" /> | ||
<link rel="stylesheet" href="../../docs/_assets/css/jqm-docs.css" /> | ||
<style> | ||
|
||
#orientationText { | ||
font-size: x-large; | ||
font-weight: bold; | ||
margin: 1em; | ||
} | ||
|
||
</style> | ||
<script src="../../js/jquery.js"></script> | ||
<script data-main="../../js/jquery.mobile" src="../../external/requirejs/require.js"></script> | ||
<script> | ||
|
||
$( document ).one( "pageinit", function() { | ||
function updateOrientation() | ||
{ | ||
$( "#orientationText" ).text( $.event.special.orientationchange.orientation() ); | ||
} | ||
|
||
updateOrientation(); | ||
$( window ).bind( $.support.orientation ? "orientationchange" : "resize", updateOrientation); | ||
}); | ||
|
||
</script> | ||
</head> | ||
|
||
<body> | ||
<div data-role="page"> | ||
<div data-role="header"><h1>Orientation Test</h1></div> | ||
<div data-role="content"> | ||
<p>The current device orientation is displayed below. It should *ALWAYS* be correct!</p> | ||
<div id="orientationText">Orientation Not Supported!</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |