From 0e8e59ac104b00e8c0a093357894053621bf0d25 Mon Sep 17 00:00:00 2001 From: Arunvel Sriram Date: Mon, 27 May 2019 00:22:46 +0530 Subject: Smooth scroll to contact section --- static/js/main.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- cgit v1.2.3 From a8fb434c01104c35f097e93f5253ad35deb32e3c Mon Sep 17 00:00:00 2001 From: Arunvel Sriram Date: Mon, 27 May 2019 00:29:19 +0530 Subject: Format code --- static/js/main.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index 8f9bb0c..2f1d09b 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -16,24 +16,24 @@ let menuBtn = $("#menuBar"); -menuBtn.click(function(){ +menuBtn.click(function() { $('.hamburger-menu').toggleClass('animate'); - if($(".secondaryMenu").hasClass("active")){ - + if ($(".secondaryMenu").hasClass("active")) { + $(".secondaryMenu").removeClass("active"); - setTimeout(function(){ + setTimeout(function() { $(".primaryMenu").addClass("active"); - },400); + }, 400); + - } else { $(".primaryMenu").removeClass("active"); - - setTimeout(function(){ + + setTimeout(function() { $(".secondaryMenu").addClass("active"); - },350); + }, 350); } }); @@ -46,18 +46,18 @@ function scrollTo(target) { $("html, body").animate({ scrollTop: top }, duration, changeHash); } -$(document).ready(function(){ +$(document).ready(function() { var elements = $(".sidebar > .main-info *"); console.log(elements); - for(let i = 0; i < elements.length; i++){ - setTimeout(function(){ + for (let i = 0; i < elements.length; i++) { + setTimeout(function() { $(elements[i].tagName).addClass("bs"); - }, (400 * i) - 90 * i ); + }, (400 * i) - 90 * i); } - setTimeout(function(){ + setTimeout(function() { $(".main-content").addClass("active"); }, 1900); -- cgit v1.2.3