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 502 forks source link

Intro Content - no active stat wanted #163

Open bukowskicharles opened 7 years ago

bukowskicharles commented 7 years ago

I have some introduction content before the sections with the „real“ content. Although none of the sections are visible on the screen my navigation has the „current“ class on the first item.

Some content

Some more content

section-1

section-2

section-3

section-4

Now, when I’m seeing the „#Some content“ Box which is pretty huge/high and fills the whole window my navigation shows the first li as active / current although the first section is not visible at all.

Any recommendations how to fix this?

Thanks in advance! Fabi

davist11 commented 7 years ago

You could probably add a navigation item for this intro section, but then hide it visually on the page.

bukowskicharles commented 7 years ago

Perfect! Thanks!

Just in case anyone is dealing with the same issue - you can handle it like this:

<ul>
  <li style="display: none;"><a href="/url/#doesnotexist">Hide This!</a></li>
  <li><a href="/url/#section-anchor-1">One</a></li>
  <li><a href="/url/#section-anchor-2">Two</a></li>
  <li><a href="/url/#section-anchor-3">Three</a></li>
  <li><a href="/url/#section-anchor-4">Four</a></li>
</ul>