diff --git a/src/components/Header.tsx b/src/components/Header.tsx
index abbc88d..c651c1e 100644
--- a/src/components/Header.tsx
+++ b/src/components/Header.tsx
@@ -1,5 +1,6 @@
import { useState } from 'react'
-import { Link } from 'react-router-dom'
+import { Link, useLocation, useNavigate } from 'react-router-dom'
+import { smoothScrollToElement } from '@/utils/scroll'
import { Container } from './Container'
import { Button } from './Button'
import pmyceliumLogo from '../images/logos/mainlogo.svg'
@@ -9,6 +10,17 @@ import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline'
export function Header() {
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)
+ const navigate = useNavigate()
+ const location = useLocation()
+
+ const handleGetConnectorClick = () => {
+ if (location.pathname === '/network') {
+ smoothScrollToElement('download', 1200)
+ } else {
+ navigate('/network')
+ }
+ }
+
return (
-
+ smoothScrollToElement('download', 1200)}
+ >
Get Started
{
- const el = document.getElementById('node-how-it-works')
- if (el) {
- el.scrollIntoView({ behavior: 'smooth', block: 'start' })
- }
- }}
+ onClick={() => smoothScrollToElement('node-how-it-works', 1200)}
>
How it works
diff --git a/src/utils/scroll.ts b/src/utils/scroll.ts
new file mode 100644
index 0000000..167463f
--- /dev/null
+++ b/src/utils/scroll.ts
@@ -0,0 +1,28 @@
+export function smoothScrollToElement(id: string, duration = 800) {
+ const element = document.getElementById(id)
+ if (!element) return
+
+ const startY = window.scrollY || window.pageYOffset
+ const targetRect = element.getBoundingClientRect()
+ const targetY = startY + targetRect.top
+ const startTime = performance.now()
+
+ function easeInOutQuad(t: number) {
+ return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t
+ }
+
+ function step(currentTime: number) {
+ const elapsed = currentTime - startTime
+ const progress = Math.min(elapsed / duration, 1)
+ const eased = easeInOutQuad(progress)
+ const nextY = startY + (targetY - startY) * eased
+
+ window.scrollTo(0, nextY)
+
+ if (progress < 1) {
+ requestAnimationFrame(step)
+ }
+ }
+
+ requestAnimationFrame(step)
+}