I’m looking to recreate the effect used on this site: http://www.brizk.com/
The site uses one large page that scrolls down. As you scroll down and pass different sections the menu navigation on the left changes css class to “current” as the corresponding div comes into view.
I presume this can be done with jQuery using $(window).height();
I’m fairly new to jQuery and what I want to write is something like this (in laymans terms):
- Get height of browser window
– if div#content1 is 100px from top and/or 200px from bottom change menu a#link1 to ‘.current’
– else remove .current from all menu a links
… and repeat for 4 different content divs.
Can anyone point me in the right direction..?
Thanks.
I didn’t look at the code example (it’s more fun to challenge myself :P) but this is how I would do it – demo here.
I saved the position of each element block to minimize the number of DOM calls, then just searched through the array. To help you understand some of the variables.
Script: