From 85a72084851eb105fbc7b89c9f40422dfbfb182a Mon Sep 17 00:00:00 2001 From: Dave Cross Date: Mon, 26 Jan 2015 20:54:02 +0000 Subject: [PATCH] Added scroll to internal links. --- js/main.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 8bdb4bd021..53e66154be 100644 --- a/js/main.js +++ b/js/main.js @@ -9,4 +9,19 @@ function setCounter () { $('#counter').html( daysToGo() + " Days to go" ); } -$( document ).ready( setCounter ); +$( document ).ready(function() { + setCounter; + + $('a[href^="#"]').on('click',function (e) { + e.preventDefault(); + + var target = this.hash; + var $target = $(target); + + $('html, body').stop().animate({ + 'scrollTop': $target.offset().top + }, 900, 'swing', function () { + window.location.hash = target; + }); + }); +} );