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

Commit

Permalink
small refactor to simplify newActiveIndex tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbender committed Feb 26, 2011
1 parent 86befde commit 20dce2c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/jquery.mobile.navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
if( fromHashChange ){

// determine new page index
var newActiveIndex = null;
var newActiveIndex;

// check if url is in history and if it's ahead or behind current page
$.each( urlHistory.stack, function( i ){
Expand All @@ -304,7 +304,7 @@
});

// save new page index
urlHistory.activeIndex = ( newActiveIndex != null ? newActiveIndex : urlHistory.activeIndex );
urlHistory.activeIndex = newActiveIndex ? newActiveIndex : urlHistory.activeIndex;

//if it's a back, use reverse animation
if( back ){
Expand Down

1 comment on commit 20dce2c

@martinkou
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the newActiveIndex found by the $.each() loop is 0, then urlHistory.activeIndex wouldn't change to that. The null is significant for distinguishing between a "not found" result and a index = 0 result (which is still a perfectly valid result).

Please sign in to comment.