first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-12-23 05:09:28 -05:00
commit d848bcd61c
971 changed files with 172537 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
import { useEffect } from 'react'
const SmoothScroll = () => {
useEffect(() => {
// Function to handle the smooth scroll behavior
const handleClick = (e) => {
e.preventDefault()
// Extract the href value from the clicked anchor
const href = e.currentTarget.getAttribute('href')
// Find the element with the corresponding id and scroll into view
const targetElement = document.querySelector(href)
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth'
})
}
}
// Attach the click event listener to all anchor elements
const anchors = document.querySelectorAll('a[href^="#"]')
anchors.forEach((anchor) => {
anchor.addEventListener('click', handleClick)
})
// Cleanup: remove event listener on component unmount
return () => {
anchors.forEach((anchor) => {
anchor.removeEventListener('click', handleClick)
})
}
}, [])
}
export default SmoothScroll