Permalink
Browse files

add the ability to disable native orientation change support Fixes #793

the frequency of the triggered event in certain android releases ( 2.1, 2.2) appears to be dependent on a host of things other than an actual orientation change, eg alerts, zoom, and scrolling. This provides a way for the user to disable it in favor for using throttled resize while still making use of the window.orientation where its available for reliability
  • Loading branch information...
johnbender committed Oct 4, 2011
1 parent ff97202 commit 57079e1d6bdfed77a67f1bd0480ac4a53fe56caf
Showing with 6 additions and 2 deletions.
  1. +3 −0 js/jquery.mobile.core.js
  2. +3 −2 js/jquery.mobile.event.js
View
@@ -53,6 +53,9 @@
pushStateEnabled: true,
+ // turn of binding to the native orientationchange due to android orientation behavior
+ orientationChangeEnabled: true,
+
// Support conditions that must be met in order to proceed
// default enhanced qualifications are media query support OR IE 7+
gradeA: function(){
@@ -190,7 +190,7 @@ $.event.special.swipe = {
setup: function() {
// If the event is supported natively, return false so that jQuery
// will bind to the event using DOM methods.
- if ( $.support.orientation ) {
+ if ( $.support.orientation && $.mobile.orientationChangeEnabled ) {
return false;
}
@@ -204,7 +204,7 @@ $.event.special.swipe = {
teardown: function(){
// If the event is not supported natively, return false so that
// jQuery will unbind the event using DOM methods.
- if ( $.support.orientation ) {
+ if ( $.support.orientation && $.mobile.orientationChangeEnabled ) {
return false;
}
@@ -216,6 +216,7 @@ $.event.special.swipe = {
// Save a reference to the bound event handler.
var old_handler = handleObj.handler;
+
handleObj.handler = function( event ) {
// Modify event object, adding the .orientation property.
event.orientation = get_orientation();

0 comments on commit 57079e1

Please sign in to comment.