diff options
author | Arunvel Sriram <arunvelsriram@gmail.com> | 2019-05-26 21:52:46 +0300 |
---|---|---|
committer | Arunvel Sriram <arunvelsriram@gmail.com> | 2019-05-26 21:52:46 +0300 |
commit | 0e8e59ac104b00e8c0a093357894053621bf0d25 (patch) | |
tree | f5a895915703e1ec7f02db41c95e5e774621ef3d | |
parent | 8e97d84a1c23c75aeb4a7e843aaa37e683ff062d (diff) |
Smooth scroll to contact section
-rw-r--r-- | static/js/main.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/static/js/main.js b/static/js/main.js index 41ca242..8f9bb0c 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -37,6 +37,15 @@ menuBtn.click(function(){ } }); +function scrollTo(target) { + const top = $(target).offset().top; + const duration = 500; + const changeHash = function() { + location.hash = target + }; + $("html, body").animate({ scrollTop: top }, duration, changeHash); +} + $(document).ready(function(){ var elements = $(".sidebar > .main-info *"); @@ -52,4 +61,9 @@ $(document).ready(function(){ $(".main-content").addClass("active"); }, 1900); + $("#sidebar a.btn[href='#contact']").on("click", function (event) { + event.preventDefault(); + + scrollTo($.attr(this, "href")); + }); });
\ No newline at end of file |