jimmynotjim / scrollnav

A dependency free JavaScript plugin for auto generating single page navigation
http://scrollnav.com
MIT License
461 stars 127 forks source link

Cannot modify Offset #111

Open ekntrtmz opened 3 years ago

ekntrtmz commented 3 years ago

Using the newest version of Scrollnav.js:

const content = document.querySelector('.main-content');
const nodeTarget = document.querySelector('.main-navigation');

scrollnav.init(content, {
   sections: 'h1',
   subSections: 'h2',
   insertTarget: nodeTarget,
   scrollOffset: 400 // not working
 });

Unfortunately, after successfully initializing the plugin, there is an offset when triggering the scroll event. I am using a sticky sidebar which may cause the offset.

How can I add scroll offset?

denniserdmann commented 3 years ago

Same here. I want to scroll the container exactly to the headline. At the moment it seems like its 50% offset of screen height.