davist11 / jQuery-One-Page-Nav

Smooth scrolling and smart navigation when user scrolls on one-page sites.
http://davist11.github.com/jQuery-One-Page-Nav/
MIT License
1.52k stars 501 forks source link

How to set the offset without editing jquery.nav.js? #162

Closed Alecto closed 7 years ago

Alecto commented 7 years ago

I need 40px offset from top. Is there any way to customize this option? Something like this $('#navbar').onePageNav({ 'scrollOffset': 117 });

davist11 commented 7 years ago

Check out this demo

http://davist11.github.io/jQuery-One-Page-Nav/top.html

Alecto commented 7 years ago

I can not use margin-top, this is not allowed in the design. As a result, the menu closes part of the section. The ideal way is to offset, but for this i need to edit the library.

davist11 commented 7 years ago

It has zero impact on the design if you use a negative top margin and top padding.

Alecto commented 7 years ago

I've already tried it. As I said, this method can not be applied, because in the design of the sections, template have different predefined indents, changing which is prohibited design requirements. Why do not you want to add this option to the plugin? Because I'm not the first one to whom this option is necessary.

davist11 commented 7 years ago

I'm not sure what predefined indents means. I do not want to add it back to the plugin because it is more complexity to add, you can't change the value across sections, and you can't adjust it responsively. Using a CSS approach simplifies and solves all of this easily.