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

Commit

Permalink
Navigation: resetActivePageHeight() on pageshow but wait for window.load
Browse files Browse the repository at this point in the history
This fixes the problem whereby header and footer heights are miscalculated when
showing the initial page, because during the initial page load, pageshow
happens before window.load, meaning that the CSS may not yet be loaded,
affecting header and footer heights.

Re gh-7134
  • Loading branch information
Gabriel Schulhof committed Feb 24, 2014
1 parent 6dcea68 commit 65ad2f9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion js/jquery.mobile.navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ define( [

// resolved on domready
var domreadyDeferred = $.Deferred(),

// resolved and nulled on window.load()
loadDeferred = $.Deferred(),
documentUrl = $.mobile.path.documentUrl,

// used to track last vclicked element to make sure its value is added to form data
Expand Down Expand Up @@ -423,13 +426,29 @@ define( [
$.mobile.pageContainer.pagecontainer();

//set page min-heights to be device specific
$.mobile.document.bind( "pageshow", $.mobile.resetActivePageHeight );
$.mobile.document.bind( "pageshow", function() {

// We need to wait for window.load to make sure that styles have already been rendered,
// otherwise heights of external toolbars will have the wrong value
if ( loadDeferred ) {
loadDeferred.done( $.mobile.resetActivePageHeight );
} else {
$.mobile.resetActivePageHeight();
}
});
$.mobile.window.bind( "throttledresize", $.mobile.resetActivePageHeight );

};//navreadyDeferred done callback

$( function() { domreadyDeferred.resolve(); } );

$.mobile.window.load( function() {

// Resolve and null the deferred
loadDeferred.resolve();
loadDeferred = null;
});

$.when( domreadyDeferred, $.mobile.navreadyDeferred ).done( function() { $.mobile._registerInternalEvents(); } );
})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
Expand Down

0 comments on commit 65ad2f9

Please sign in to comment.