Team:NCTU Formosa/source/head
From 2013.igem.org
(Difference between revisions)
Line 29: | Line 29: | ||
topMenu = $("#toc"), | topMenu = $("#toc"), | ||
topMenuHeight = 35, | topMenuHeight = 35, | ||
- | |||
menuItems = topMenu.find("a"), | menuItems = topMenu.find("a"), | ||
- | |||
scrollItems = menuItems.map(function(){ | scrollItems = menuItems.map(function(){ | ||
var item = $($(this).attr("href")); | var item = $($(this).attr("href")); | ||
Line 55: | Line 53: | ||
e.preventDefault(); | e.preventDefault(); | ||
}); | }); | ||
- | |||
- | |||
$(window).scroll(function(){ | $(window).scroll(function(){ | ||
if(!noScrollAction){ | if(!noScrollAction){ | ||
- | |||
var fromTop = $(this).scrollTop()+topMenuHeight; | var fromTop = $(this).scrollTop()+topMenuHeight; | ||
- | |||
- | |||
var cur = scrollItems.map(function(){ | var cur = scrollItems.map(function(){ | ||
if ($(this).offset().top < fromTop) | if ($(this).offset().top < fromTop) | ||
return this; | return this; | ||
}); | }); | ||
- | |||
cur = cur[cur.length-1]; | cur = cur[cur.length-1]; | ||
var chk=0; | var chk=0; | ||
Line 75: | Line 67: | ||
if (lastId !== id) { | if (lastId !== id) { | ||
lastId = id; | lastId = id; | ||
- | |||
menuItems | menuItems | ||
.parent().removeClass("active") | .parent().removeClass("active") |
Revision as of 14:04, 19 September 2013