Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery scrollTo fixed header offset

I am using the jQuery scrollTo plugin as you can see on the page which I'm building http://portfolio.tomvervoort.net/

Because of the 300px fixed header the content moves under the header. You can see this clearly when you click the about button in the menu. Is it possible to add an 300px offset to the scrollTo script so everything stays positioned under the header/menu?

like image 983
Tom Avatar asked Jun 12 '12 23:06

Tom


2 Answers

You can use the "offset" setting as described on:

http://flesler.blogspot.com.ar/2007/10/jqueryscrollto.html

Something like:

$.scrollTo(newLoc, o.scrollSpeed, {
     // ...
     offset:-300
});
like image 85
Ariel Flesler Avatar answered Nov 04 '22 14:11

Ariel Flesler


You could try changing this line in jquery.nav.js:

$.scrollTo(newLoc, o.scrollSpeed, {

to

$.scrollTo($('newLoc').offset().top-300, o.scrollSpeed, { 

So instead of telling scrollto to scroll to exactly that element, you get the position of the element yourself and subtract 300

like image 25
Andy Avatar answered Nov 04 '22 16:11

Andy