Skip to content

Commit

Permalink
- Added back button functionality based on anchor links
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarotrigo committed Sep 27, 2013
1 parent ae58be3 commit fe2e154
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion jquery.fullPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@
//more than once if the page is scrolling
isMoving = true;

location.hash = element.data('anchor');
if(typeof element.data('anchor') != 'undefined'){
location.hash = element.data('anchor');
}else{
location.hash = '';
}

dest = $(element).position();
dtop = dest != null ? dest.top : null;
Expand All @@ -160,6 +164,17 @@
}
}

//detecting any change on the URL to scroll to the given anchor link
//(a way to detect back history button as we play with the hashes on the URL)
$(window).on('hashchange',function(){
var value = window.location.hash.replace('#', '');
var element = $('[data-anchor="'+value+'"]');

element.addClass('active').siblings().removeClass('active');
scrollPage(element);
});


/**
* Sliding with arrow keys, both, vertical and horizontal
*/
Expand Down

0 comments on commit fe2e154

Please sign in to comment.