Permalink
Browse files

active current link in navigation

  • Loading branch information...
1 parent ee4c826 commit a6984d35d6f387a3a3f49c475e5d66ea5594d879 @digitaltom digitaltom committed Feb 28, 2013
Showing with 25 additions and 7 deletions.
  1. +2 −2 css/hackweek.css
  2. +5 −5 index.html
  3. +18 −0 js/hackweek.js
View
4 css/hackweek.css
@@ -28,7 +28,7 @@ li {
height: 100%;
z-index: 0;
}
-#navigation{
+#navigation {
margin-left: 20px;
margin-top: 20px;
text-align: left;
@@ -40,7 +40,7 @@ li {
text-transform: uppercase;
cursor: pointer;
}
-.active{
+#navigation .active{
font-weight: bold;
}
.inactive{
View
10 index.html
@@ -9,19 +9,19 @@
<body>
<div id="navigation">
<div id="start-link" class="logo-color"></div>
- <li id="what-is-link" class="active">
+ <li id="what-is-link">
what is hack week?
</li>
- <li id="projects-link" class="active">
+ <li id="projects-link">
projects
</li>
- <li id="agenda-link" class="active">
+ <li id="agenda-link">
agenda
</li>
- <li id="join-link" class="active">
+ <li id="join-link">
join
</li>
- <li id="where-link" class="active">
+ <li id="where-link">
where?
</li>
View
18 js/hackweek.js
@@ -89,6 +89,24 @@ $(function () {
right: percent_scrolled_out * -500})
}
+ /* set active page in navigation menu */
+ if ($(window).scrollTop() > $('#join').position().top + $('#join').height() / 2) {
+ $('#navigation li').removeClass('active')
+ $('#where-link').addClass('active')
+ } else if ($(window).scrollTop() > $('#agenda').position().top + $('#agenda').height() / 2) {
+ $('#navigation li').removeClass('active')
+ $('#join-link').addClass('active')
+ } else if ($(window).scrollTop() > $('#projects').position().top + $('#projects').height() / 2) {
+ $('#navigation li').removeClass('active')
+ $('#agenda-link').addClass('active')
+ } else if ($(window).scrollTop() > $('#what-is').position().top + $('#what-is').height() / 2) {
+ $('#navigation li').removeClass('active')
+ $('#projects-link').addClass('active')
+ } else if ($(window).scrollTop() > $('#start').position().top + $('#start').height() / 2) {
+ $('#navigation li').removeClass('active')
+ $('#what-is-link').addClass('active')
+ }
+
})

0 comments on commit a6984d3

Please sign in to comment.