feat: better fotter

This commit is contained in:
2025-11-07 15:43:46 +03:30
parent 81a10f6269
commit 3ceec02356
16 changed files with 292 additions and 78 deletions
+40
View File
@@ -0,0 +1,40 @@
// hooks/useScroll.js
import { useCallback } from 'react';
export const useScroll = () => {
const scrollToSection = useCallback((sectionId, offset = 0) => {
if (typeof window === 'undefined') return;
const element = document.getElementById(sectionId);
if (element) {
const elementPosition = element.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - offset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
}
}, []);
const scrollToSectionWithHeader = useCallback((sectionId) => {
const headerOffset = 80; // Adjust based on your header height
scrollToSection(sectionId, headerOffset);
}, [scrollToSection]);
const scrollToTop = useCallback(() => {
if (typeof window === 'undefined') return;
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}, []);
return {
scrollToSection,
scrollToSectionWithHeader,
scrollToTop
};
};