Skip to content

Added smooth scrolling to the anchors. #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: source
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<![endif]-->
</head>

<body class="home">
<body class="home" id="header">
<% include templates/navbar %>
<!-- Header -->
<header id="head">
Expand Down
17 changes: 16 additions & 1 deletion src/templates/javascript.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,22 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/i18next/1.6.3/i18next-1.6.3.min.js" type="text/javascript"></script>
<script src="assets/js/headroom.min.js"></script>
<script src="assets/js/jQuery.headroom.min.js"></script>

<script>
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should go to main.js

<script type="text/javascript" src="assets/js/main<% if(!data.dev) { %>.min<% } %>.js"></script>
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-MJLSWH"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/navbar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav pull-right">
<li class="active"><a href="#">Home</a></li>
<li class="active"><a href="#header">Home</a></li>
<li><a href="#">Blog</a></li>
<li><a href="http://discuss.butterproject.org/">Forum</a></li>
<li><a href="https://github.com/butterproject">GitHub</a></li>
Expand Down