I'm having all sorts of issues with a stick nav and smooth scrolling. I just don't know enough about jQuery to troubleshoot. I'm using a smooth scrolling snippet from Chris Coyer: http://css-tricks.com/snippets/jquery/smooth-scrolling/. My page is here: http://clients.ekcetera.com/agivingchance.
Here are my problems:
Any suggestions?
Thanks in advance!
1. Use this code from Devin Sturgeon's comment about the Smooth Scrolling post. Plus I've added a little subtraction to make up for your sticky header. Adjust to liking.
// your functions go here
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 181
}, 1000);
return false;
}
}
});
2. Move all your anchors to the actual element you want to scroll to.
(ref: http://css-tricks.com/snippets/jquery/smooth-scrolling/#comment-197181)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With