Difference between revisions of "Team:DTU-Denmark/jsnavbarfade"

Line 29: Line 29:
 
         });
 
         });
 
     } else {
 
     } else {
         $(".navbar").load("https://2017.igem.org/Team:DTU-Denmark/navbarhtml?action=raw&ctype=text/html");
+
         $(".navbar").load("https://2017.igem.org/Team:DTU-Denmark/navbarhtmltest?action=raw&ctype=text/html");
 
     }  
 
     }  
 
});
 
});

Revision as of 21:53, 1 November 2017

// loads the correct navbar and takes care of the color change on #mainpage

$(function(){

   if($('body').is('#mainpageERASETHISTOINCLUDEFADEEFFECT')){
       $(document).ready(function(){
           var scroll_start = 0;
           var startchange = $('#startchange');
           var offset = startchange.offset();
           $(document).scroll(function() {
   	
               scroll_start = $(this).scrollTop();
               if (scroll_start > offset.top - 400) {

$('.navbar').addClass('scrolledpastnav');

                   $('.dropdown-content').addClass('scrolledpastnav');

} else {

                   $('.navbar').removeClass('scrolledpastnav');
                   $('.dropdown-content').removeClass('scrolledpastnav');
               }
           });
           $(".jumptocontent").on("click", function( e ) {
               e.preventDefault();
               $("body, html").animate({ 
                   scrollTop: $( $(this).attr('href') ).offset().top - 80
               }, 600);
           });
       });
   } else {
       $(".navbar").load("https://2017.igem.org/Team:DTU-Denmark/navbarhtmltest?action=raw&ctype=text/html");
   } 

});


// adds the cool smooth scroll effect when you press right navbar links

$('a[href^="#"]').on('click', function(event) {

   var target = $(this.getAttribute('href'));
   if( target.length ) {
       event.preventDefault();
       $('html, body').stop().animate({
           scrollTop: target.offset().top - 80
       }, 700);
   }

});


// fixes the right navbar on the page when you scroll past it

var rightnavbarTop = $('.rightnavbar').offset().top; $(window).scroll(function() {

   var currentScroll = $(window).scrollTop();
   if (currentScroll >= rightnavbarTop - 80) {
       $('.rightnavbar').addClass('fixedrightnavbar');
   } else {
       $('.rightnavbar').removeClass('fixedrightnavbar');
   }

});