$(document).ready(function () {
$(document).on("scroll", onScroll); $('.tab-content a[href*="#"]').on('click', function (e) { e.preventDefault(); $(document).off("scroll"); $('a').each(function () { $(this).removeClass('active'); }); $(this).addClass('active'); var target = this.hash, $target = $(target); $('html, body').stop().animate({ 'scrollTop': $target.offset().top+2 }, 500, 'swing', function () { window.location.hash = target; $(document).on("scroll", onScroll); }); });
$(document).on("scroll", onScroll); function onScroll(event){ var scrollPos = $(document).scrollTop(); $('.tab-content a').each(function () { var currLink = $(this); var refElement = $(currLink.attr("href")); if (refElement.position().top <= scrollPos && refElement.position().top + refElement.height() > scrollPos) { $('.tab-content a').removeClass("active"); currLink.addClass("active"); } else{ currLink.removeClass("active"); }
function activateElement(element,menuElement){ $('#menu1').removeClass("in"); $('#menu1').removeClass("active"); $('#menu2').removeClass("active"); $('#menu2').removeClass("in");
$('#menu3').removeClass("active"); $('#menu3').removeClass("in");
$('#menu4').removeClass("active"); $('#menu4').removeClass("in");
$('#menu5').removeClass("active"); $('#menu5').removeClass("in");
$('#menu6').removeClass("active"); $('#menu6').removeClass("in");
$('#navbarIntroduction').removeClass("active"); $('#navbarPresentation').removeClass("active"); $('#navbarProject').removeClass("active"); $('#navbarProcedures').removeClass("active"); $('#navbarPractices').removeClass("active"); $('#navbarProspects').removeClass("active"); element.addClass("active"); element.addClass("in"); menuElement.addClass("active"); } if((currLink.attr('href') === "#presentation" || currLink.attr('href') === "#team" || currLink.attr('href') === "#attributions" || currLink.attr('href') === "#collaborations" || currLink.attr('href') === "#achievements") && !$('#menu1').hasClass("active")){ activateElement($('#menu1'),$('#navbarPresentation')); } else if ((currLink.attr('href') === "#introduction" || currLink.attr('href') === "#description" || currLink.attr('href') === "#outreach") && !$('#menu2').hasClass("active")){ activateElement($('#menu2'),$('#navbarIntroduction')); } }); }
});