Skip to content

Commit c4ea84a

Browse files
committed
Smooth scroll from header
1 parent d26974e commit c4ea84a

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

landing.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ document.addEventListener("DOMContentLoaded", function () {
88
});
99
}
1010

11+
function scrollToHowItWorks() {
12+
document.getElementById("how-it-works").scrollIntoView({
13+
behavior: "smooth",
14+
});
15+
}
16+
1117
// Add scroll effect to navigation
1218
window.addEventListener("scroll", function () {
1319
const nav = document.querySelector(".landing-nav");
@@ -69,6 +75,20 @@ document.addEventListener("DOMContentLoaded", function () {
6975
}
7076
});
7177
});
78+
79+
// Add event listeners for anchor links to prevent default and smooth scroll
80+
document.querySelectorAll('a[href="#features"]').forEach((el) => {
81+
el.addEventListener("click", (e) => {
82+
e.preventDefault();
83+
scrollToFeatures();
84+
});
85+
});
86+
document.querySelectorAll('a[href="#how-it-works"]').forEach((el) => {
87+
el.addEventListener("click", (e) => {
88+
e.preventDefault();
89+
scrollToHowItWorks();
90+
});
91+
});
7292
});
7393
// Animated counters for stats
7494
function animateCounter(el) {
@@ -123,9 +143,15 @@ function validateEmail(email) {
123143
return re.test(email);
124144
}
125145

126-
// Add to global scope for inline onclick handlers
127-
window.scrollToFeatures = function () {
128-
document.getElementById("features").scrollIntoView({
129-
behavior: "smooth",
130-
});
131-
};
146+
// Add to global scope for inline onclick handlers
147+
window.scrollToFeatures = function () {
148+
document.getElementById("features").scrollIntoView({
149+
behavior: "smooth",
150+
});
151+
};
152+
153+
window.scrollToHowItWorks = function () {
154+
document.getElementById("how-it-works").scrollIntoView({
155+
behavior: "smooth",
156+
});
157+
};

0 commit comments

Comments
 (0)