-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathorientation.js
27 lines (23 loc) · 860 Bytes
/
orientation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var previousOrientation = window.orientation;
var checkOrientation = function()
{
if(window.orientation !== previousOrientation)
{
previousOrientation = window.orientation;
// Orientation changed
// alert("orietnat changed...");
setTimeout(function() {
$.ajax( { "url" : "http://www.learnjquery.org/games/Tig_jsGE/addTester.php",
type : "POST",
data: { "width" : $(window).width(), "height" : $(window).height() },
success: function(msg) { }
});
}, 2000);
}
};
$(document).ready(function()
{
window.addEventListener("resize", checkOrientation, false);
window.addEventListener("orientationchange", checkOrientation, false);
setInterval(checkOrientation, 2000); // (optional) Android doesn't always fire orientationChange on 180 degree turns
});