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

Commit

Permalink
when touch overflow scrolling is supported and enabled, user scaling …
Browse files Browse the repository at this point in the history
…can create serious usability issues where it's difficult to get zoomed back out. This disables user scaling when that overflow scrolling is enabled (currently only projected for ios5 support)
  • Loading branch information
scottjehl committed Sep 27, 2011
1 parent 1ad3eea commit 47480d6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions js/jquery.mobile.fixHeaderFooter.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

(function( $, undefined ) {

// Enable touch overflow scrolling when it's natively supported
$.mobile.touchOverflowEnabled = true;

// Enabled zoom when touch overflow is enabled. Can cause usability issues, unfortunately
$.mobile.touchOverflowZoomEnabled = false;

$( document ).bind( "pagecreate", function( event ) {
if( $.support.touchOverflow && $.mobile.touchOverflowEnabled ){

Expand Down
18 changes: 18 additions & 0 deletions js/jquery.mobile.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@
}
}
});

// This function injects a meta viewport tag to prevent scaling. Off by default, on by default when touchOverflow scrolling is enabled
function disableZoom() {
var cont = "user-scalable=no",
meta = $( "meta[name='viewport']" );

if( meta.length ){
meta.attr( "content", meta.attr( "content" ) + ", " + cont );

This comment has been minimized.

Copy link
@staabm

staabm Sep 27, 2011

Contributor

What happens when the user given meta tag defines user-scalabake=yes?

This comment has been minimized.

Copy link
@scottjehl

scottjehl Sep 27, 2011

Good question. Maybe we should test if this overrides it or not. It's painful we had to add this at all, definitely don't want to disable zoom...

}
else{
$( "head" ).prepend( "<meta>", { "name": "viewport", "content": cont } );
}
}

// if touch-overflow is enabled, disable user scaling, as it creates usability issues
if( $.support.touchOverflow && $.mobile.touchOverflowEnabled && !$.mobile.touchOverflowZoomEnabled ){
disableZoom();
}

// initialize events now, after mobileinit has occurred
$.mobile._registerInternalEvents();
Expand Down

0 comments on commit 47480d6

Please sign in to comment.