1
Fork 0

Add scroll to top on navbar press

This commit is contained in:
Jake Howard 2017-07-10 09:50:49 +01:00
parent e5c62c99b1
commit d30fdd40dc
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 11 additions and 1 deletions

View file

@ -1,5 +1,5 @@
<header id="header" {{ if .IsHome }}class="alt"{{ end }}> <header id="header" {{ if .IsHome }}class="alt"{{ end }}>
<h1><a href="/">{{ title .Site.Title }}</a></h1> <h1><a href="/" class="navbar-brand">{{ title .Site.Title }}</a></h1>
<nav id="nav"> <nav id="nav">
<ul> <ul>
{{ $home := .Site.GetPage "home" }} {{ $home := .Site.GetPage "home" }}

View file

@ -31,3 +31,13 @@ $(document).ready(function () {
}); });
}); });
$('.navbar-brand').bind('click', function (event) {
if ($('html').scrollTop() > 100) {
$('html, body').stop().animate({
scrollTop: 0
}, 500);
} else {
window.location = '/';
}
event.preventDefault();
});