Revert "refactor sticky scroll handler"

This reverts commit da9d7f8eb3.
This commit is contained in:
2025-10-09 00:20:39 +03:00
parent 5a9973d5b3
commit dea9a59127
4 changed files with 78 additions and 214 deletions

View File

@@ -41,36 +41,10 @@ export function ScrollHandlerProvider({ children }: { children: ReactNode }) {
// Function to scroll to a specific category
const scrollToCategory = useCallback((categoryId: number) => {
const categoryRef = categoryRefs.current?.[categoryId];
// Use a more stable approach to find the scroll container
const findScrollContainer = () => {
const antApp = document.querySelector('.ant-app') as HTMLElement;
if (antApp && antApp.scrollHeight > antApp.clientHeight) {
return antApp;
}
const appContainer = document.querySelector('[class*="App"]') as HTMLElement;
if (appContainer && appContainer.scrollHeight > appContainer.clientHeight) {
return appContainer;
}
return document.documentElement;
};
const scrollContainer = findScrollContainer();
if (categoryRef && scrollContainer) {
// Get the position of the category relative to the scroll container
const categoryRect = categoryRef.getBoundingClientRect();
const containerRect = scrollContainer.getBoundingClientRect();
// Calculate the target scroll position
const targetScrollTop = scrollContainer.scrollTop + categoryRect.top - containerRect.top;
// Smooth scroll to the target position
scrollContainer.scrollTo({
top: targetScrollTop,
behavior: "smooth"
if (categoryRef) {
categoryRef.scrollIntoView({
behavior: "smooth",
block: "start",
});
}
}, []);