Template:Team:Berkeley/sidenav.js
From 2013.igem.org
(Difference between revisions)
(2 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
$(window).scroll(function () { | $(window).scroll(function () { | ||
if ($(window).scrollLeft() > 0) { | if ($(window).scrollLeft() > 0) { | ||
- | $('#navbar').css('left', -($(window).scrollLeft()) + | + | $('#navbar').css('left', -($(window).scrollLeft()) + 30); |
} | } | ||
else { | else { | ||
- | $('#navbar').css('left', | + | $('#navbar').css('left', 30); |
} | } | ||
} | } | ||
Line 10: | Line 10: | ||
- | var offset = | + | var offset = 800; |
$('.navbar li a').click(function(event) { | $('.navbar li a').click(function(event) { | ||
+ | window.location.hash = $(this).attr('href') | ||
event.preventDefault(); | event.preventDefault(); | ||
$($(this).attr('href'))[0].scrollIntoView(); | $($(this).attr('href'))[0].scrollIntoView(); | ||
scrollBy(0, -offset); | scrollBy(0, -offset); | ||
}); | }); |
Latest revision as of 19:47, 27 October 2013
$(window).scroll(function () {
if ($(window).scrollLeft() > 0) { $('#navbar').css('left', -($(window).scrollLeft()) + 30); } else { $('#navbar').css('left', 30); }
} );
var offset = 800;
$('.navbar li a').click(function(event) {
window.location.hash = $(this).attr('href') event.preventDefault(); $($(this).attr('href'))[0].scrollIntoView(); scrollBy(0, -offset);
});