Revert "refactor sticky scroll handler"
This reverts commit da9d7f8eb3.
This commit is contained in:
@@ -15,28 +15,10 @@ export function FloatingButton() {
|
||||
const { showScrollTop } = useScrollHandler();
|
||||
|
||||
const scrollToTop = useCallback(() => {
|
||||
// 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 (scrollContainer) {
|
||||
scrollContainer.scrollTo({
|
||||
top: 0,
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: "smooth",
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user