Permalink
Browse files

fixed binding of orientationchange event (was on document, but only w…

…orks on window). Moreover, it is now bound using 'bind' and not 'live'
  • Loading branch information...
1 parent 4497d13 commit 04e75b07cd86e29c0455846520be18732772b652 @bestform bestform committed Jun 8, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 experiments/scrollview/scrollview.js
@@ -55,6 +55,6 @@ $(":jqmData(role='page')").live("pageshow", function(event) {
ResizePageContentHeight(event.target);
});
-$(document).live("orientationchange", function(event) {
+$(window).bind("orientationchange", function(event) {
ResizePageContentHeight($(".ui-page"));
});

1 comment on commit 04e75b0

Also, I have noticed unreliable behavior with the ResizePageContentHeight function on Android devices (the device makes the viewable area of the page too small inside the viewport). Most unfortunately, it seems Android devices inconsistently handle the orientationchange event and the resulting value of the screen width. (See http://stackoverflow.com/questions/1649086/detect-rotation-of-android-phone-in-the-browser-with-javascript). I was able to resolve this by just relying on the 'resize' event instead as it seems to be much more reliable.

Here's what I did:

if (!navigator.userAgent.match(/android/i)) {
    $(window).bind("orientationchange", function(event) {
        ResizePageContentHeight($(".ui-page"));
    });
} else {
    $(window).bind("resize", function(event) {
        ResizePageContentHeight($(".ui-page"));
    });
}

And thanks for the nice plugin, BTW!

Please sign in to comment.