- clean coupon on success order
- in menu on clicking on the sticky categories make scroll jump to the category title postion exactly
This commit is contained in:
2026-01-04 07:46:21 +03:00
parent f294138d30
commit 102415fe8b
3 changed files with 119 additions and 101 deletions

View File

@@ -42,12 +42,22 @@ export function ScrollHandlerProvider({ children }: { children: ReactNode }) {
const scrollToCategory = useCallback((categoryId: number) => {
const categoryRef = categoryRefs.current?.[categoryId];
if (categoryRef) {
categoryRef.scrollIntoView({
// Get the sticky header height (70px when sticky, 0 when not)
const stickyHeaderHeight = isCategoriesSticky && categoriesContainerRef.current
? categoriesContainerRef.current.offsetHeight
: 0;
// Calculate the position of the category element
const elementPosition = categoryRef.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - stickyHeaderHeight;
// Scroll to the exact position, accounting for sticky header
window.scrollTo({
top: offsetPosition,
behavior: "smooth",
block: "start",
});
}
}, []);
}, [isCategoriesSticky, categoriesContainerRef]);
return (
<ScrollHandlerContext.Provider