fixes
- 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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user