Template:Team:Berlin/igemScript
From 2014.igem.org
(Difference between revisions)
(2 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
- | + | ||
- | + | ||
// my scroll to | // my scroll to | ||
$("#main-button").click(function() { | $("#main-button").click(function() { | ||
Line 39: | Line 38: | ||
}); // end section function | }); // end section function | ||
}); // close out script | }); // close out script | ||
- | |||
- | |||
- | |||
- |
Latest revision as of 11:57, 2 October 2014
// 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