From c4ea84a313395ecd77320b6ae9bef6d13c82e38a Mon Sep 17 00:00:00 2001 From: Vandana-Ss Date: Mon, 15 Sep 2025 17:03:23 +0530 Subject: [PATCH] Smooth scroll from header --- landing.js | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/landing.js b/landing.js index 43ebc5a..fc96daf 100644 --- a/landing.js +++ b/landing.js @@ -8,6 +8,12 @@ document.addEventListener("DOMContentLoaded", function () { }); } + function scrollToHowItWorks() { + document.getElementById("how-it-works").scrollIntoView({ + behavior: "smooth", + }); + } + // Add scroll effect to navigation window.addEventListener("scroll", function () { const nav = document.querySelector(".landing-nav"); @@ -69,6 +75,20 @@ document.addEventListener("DOMContentLoaded", function () { } }); }); + + // Add event listeners for anchor links to prevent default and smooth scroll + document.querySelectorAll('a[href="#features"]').forEach((el) => { + el.addEventListener("click", (e) => { + e.preventDefault(); + scrollToFeatures(); + }); + }); + document.querySelectorAll('a[href="#how-it-works"]').forEach((el) => { + el.addEventListener("click", (e) => { + e.preventDefault(); + scrollToHowItWorks(); + }); + }); }); // Animated counters for stats function animateCounter(el) { @@ -123,9 +143,15 @@ function validateEmail(email) { return re.test(email); } -// Add to global scope for inline onclick handlers -window.scrollToFeatures = function () { - document.getElementById("features").scrollIntoView({ - behavior: "smooth", - }); -}; + // Add to global scope for inline onclick handlers + window.scrollToFeatures = function () { + document.getElementById("features").scrollIntoView({ + behavior: "smooth", + }); + }; + + window.scrollToHowItWorks = function () { + document.getElementById("how-it-works").scrollIntoView({ + behavior: "smooth", + }); + };