From fcbfc2f38004709bc2f0a43ef179d87bd7c33a47 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Fri, 17 Jun 2011 16:33:19 -0400 Subject: [PATCH] added minScrollBack feature to core options. This is the minimum scroll distance that will be jumped-to when returning to a page. By default, the distance is screen.height /2. If you really needed to disable scroll memory altogether, this could be set to Infinity. Note that disabling scroll memory altogether is almost never a good idea for usability, but the option is there. --- docs/api/globalconfig.html | 3 +++ js/jquery.mobile.core.js | 3 +++ js/jquery.mobile.navigation.js | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/api/globalconfig.html b/docs/api/globalconfig.html index a8e88b90..c2ba0e03 100755 --- a/docs/api/globalconfig.html +++ b/docs/api/globalconfig.html @@ -103,6 +103,9 @@ $(document).bind("mobileinit", function(){
defaultDialogTransition (string, default: 'pop'):
Set the default transition for dialog changes that use Ajax. Set to 'none' for no transitions by default.
+ +
minScrollBack (string, default: 150):
+
Minimum scroll distance that will be remembered when returning to a page.
loadingMessage (string, default: "loading"):
Set the text that appears when a page is loading. If set to false, the message will not appear at all.
diff --git a/js/jquery.mobile.core.js b/js/jquery.mobile.core.js index f1b75274..42a06178 100644 --- a/js/jquery.mobile.core.js +++ b/js/jquery.mobile.core.js @@ -38,6 +38,9 @@ //set default page transition - 'none' for no transitions defaultPageTransition: "slide", + + //minimum scroll distance that will be remembered when returning to a page + minScrollBack: screen.height / 2, //set default dialog transition - 'none' for no transitions defaultDialogTransition: "pop", diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 08336ced..5a042f12 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -396,7 +396,7 @@ } //if the Y location we're scrolling to is less than 10px, let it go for sake of smoothness - if( toScroll < 20 ){ + if( toScroll < $.mobile.minScrollBack ){ toScroll = 0; } @@ -453,7 +453,7 @@ //simply set the active page's minimum height to screen height, depending on orientation function resetActivePageHeight(){ - var height = jQuery.event.special.orientationchange.orientation() == "portrait" ? screen.height : screen.width, + var height = jQuery.event.special.orientationchange.orientation() === "portrait" ? screen.height : screen.width, winHeight = $( window ).height(), pageMin = Math.min( height, winHeight );