jimmynotjim / scrollnav

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

Do Something When Scrolled To. #44

Closed Incomitatum closed 10 years ago

Incomitatum commented 10 years ago

First of all, thank you for making this. I was slogging along trying to do something similar in Java, but being a noob it would take me too many cycles and was not realistic for the project I am working on.

I am wanting to use this in conjunction with a Parallax style website. Most of these have staked "slides" and when you scroll to them something fancy happens.

Since you are giving the sections classes like "scrollNav-1"... etc, what would be the best way to begin a function that says...

When "scollNav-X" is scrolled to, then do Y?

I imagine I'd write a function for each of my 10 slides, as I may want the contents to do different things for each.

I'm new to jQuery. I know the basics, and can get jQueryUI to do THINGS, but I'm not so sure how to start a function that KNOWS when you've scrolled to a specific section.

Thank you in advance for any help you can give.

-Andrew

jimmynotjim commented 10 years ago

There are callbacks in scrollNav but not for scrolling events so you'll need to do this on your own. You could watch for the "active" class on the nav items though.