Template:Team:Berlin/igemScript

From 2014.igem.org

// my scroll to $("#main-button").click(function() {

   $('html, body').animate({
       scrollTop: $("#main-featurette-row").offset().top
   }, 800);

});


$(document).ready(function(){

  // cache the window object
  $window = $(window);
   var url = window.location.href; 
   
   // passes on every "a" tag 
   $(".main-menue-ul a").each(function() {
               // checks if its the same on the address bar
           if(url == (this.href)) { 
               $(this).children("li").addClass("active");
   }


  $('section[data-type="background"]').each(function(){
    // declare the variable to affect the defined data-type
    var $scroll = $(this);
                    
     $(window).scroll(function() {
       // HTML5 proves useful for helping with creating JS functions!
       // also, negative value because we're scrolling upwards                             
       var yPos = -($window.scrollTop() / $scroll.data('speed')); 
        
       // background position
       var coords = '80% '+ yPos + 'px';

       // move the background
       $scroll.css({ backgroundPosition: coords });    
     }); // end window scroll
  });  // end section function

}); // close out script