Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iamcanadian1973/b49cba99df8fe25efc28 to your computer and use it in GitHub Desktop.
Save iamcanadian1973/b49cba99df8fe25efc28 to your computer and use it in GitHub Desktop.
When you want to highlight a navigation anchor with scrollTo
$(document).ready(function() {
$('nav.primary a').click(function(event) { // the elements you click to scroll
event.preventDefault();
var link = this; // you need this if you are using hash links on ex: a href="#link" to id="link"
$.smoothScroll({
offset: -160, // adjusts where the scroll will stop so the height of the scrolling element plus the height of the element you are scrolling to.
speed: 2000,
scrollTarget: link.hash
});
});
// waypoint alternative
// jsfiddle.net/senff/4D3bH/3/
$('nav.primary a').click(function(){
$('nav.primary a').removeClass('active');
$(this).addClass('active');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment