improvements
This commit is contained in:
@@ -7,6 +7,15 @@ export const ScrollToTop = () => {
|
||||
useEffect(() => {
|
||||
const animationFrame = window.requestAnimationFrame(() => {
|
||||
window.scrollTo({ top: 0, left: 0, behavior: 'auto' });
|
||||
const mainElement = document.querySelector('main');
|
||||
if (mainElement instanceof HTMLElement) {
|
||||
if (typeof mainElement.scrollTo === 'function') {
|
||||
mainElement.scrollTo({ top: 0, left: 0, behavior: 'auto' });
|
||||
} else {
|
||||
mainElement.scrollTop = 0;
|
||||
mainElement.scrollLeft = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return () => window.cancelAnimationFrame(animationFrame);
|
||||
|
Reference in New Issue
Block a user