Template:Team:Berkeley/sidenav.js

From 2013.igem.org

(Difference between revisions)
 
Line 1: Line 1:
$(window).scroll(function () {
$(window).scroll(function () {
     if ($(window).scrollLeft() > 0) {
     if ($(window).scrollLeft() > 0) {
-
         $('#navbar').css('left', -($(window).scrollLeft()) + 50);
+
         $('#navbar').css('left', -($(window).scrollLeft()) + 30);
     }
     }
     else {
     else {
-
         $('#navbar').css('left', 50);
+
         $('#navbar').css('left', 30);
     }
     }
}
}

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);

});