Difference between revisions of "Team:TU Delft/Header Test"

Line 354: Line 354:
 
</script>
 
</script>
 
<script>
 
<script>
$(document).ready(function() {
+
$("a[href*=#]").on('click', function(event){
+
    var href = $(this).attr("href");
$("a.sub-nav-item").click(function() {
+
    if ( /(#.*)/.test(href) ){
$("html, body").animate({
+
      var hash = href.match(/(#.*)/)[0];
scrollTop: $($(this).attr("href")).offset().top + "px"
+
      var path = href.match(/([^#]*)/)[0];
}, {
+
 
duration: 500,
+
      if (window.location.pathname == path || path.length == 0){
easing: "swing"
+
        event.preventDefault();
});
+
        $('html,body').animate({scrollTop:$(this.hash).offset().top}, 1000);
return false;
+
        window.location.hash = hash;
});  
+
      }
});
+
    }
$('a').click(function(){
+
    $('html, body').animate({
+
        scrollTop: $( $(this).attr('href') ).offset().top
+
    }, 500);
+
    return false;
+
 
});
 
});
 
</script>
 
</script>
 
</html>
 
</html>

Revision as of 13:11, 28 July 2015