Ming
Ming

Reputation: 784

Add offset to jQuery ScrollTo

Right now I am using a ScrollTo plugin as demonstrated in this fiddle. If you press the back/next button it will scroll you to the next post. The problem is that I have a fixed navigation bar and it blocks the posts. I did some research, both here and on the plugin author's blog and I learnt that you have to add an "offset" option. So I turned this

if (scroll) { 
            $.scrollTo(scroll, {
                duration: 750
            });
        }

into

if (scroll) { 
            $.scrollTo(scroll, {
                offset: -50
                duration: 750
            });
        }

However this just breaks the plugin and it stops working comepletely. I tried some other options as suggested by related posts but none of the methods worked.

/Tony

Upvotes: 3

Views: 5250

Answers (1)

Andy G
Andy G

Reputation: 19367

You need a comma between offset and duration

offset: -50,
duration: 750

I notice it works with 50, but with -50 you need to first scroll down a little. Needs a bit more work ;)

Upvotes: 1

Related Questions