Skip to content

Commit

Permalink
Added internal flag to detect back/forward use
Browse files Browse the repository at this point in the history
var state = History.getState();
if (state.internal) { }
  • Loading branch information
Danny Herran committed Jun 9, 2014
1 parent 14968aa commit db56b3c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/bundled-uncompressed/html5/jquery.history.js
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@
*/
History.onPopState = function(event,extra){
// Prepare
var stateId = false, newState = false, currentHash, currentState;
var stateId = false, newState = false, currentHash, currentState, isInternal = false;

// Reset the double check
History.doubleCheckComplete();
Expand Down Expand Up @@ -1798,6 +1798,7 @@
if ( stateId ) {
// Vanilla: Back/forward button was used
newState = History.getStateById(stateId);
isInternal = true;
}
else if ( History.expectedStateId ) {
// Vanilla: A new state was pushed, and popstate was called manually
Expand Down Expand Up @@ -1825,6 +1826,9 @@
return false;
}

// Store the internal status
newState.internal = isInternal;

// Store the State
History.storeState(newState);
History.saveState(newState);
Expand Down

0 comments on commit db56b3c

Please sign in to comment.