scroll to top button added

This commit is contained in:
Owen Rees
2023-06-20 15:00:59 +02:00
parent 5aaa1deeff
commit bcc3c74973
8 changed files with 97 additions and 40 deletions
+8
View File
@@ -0,0 +1,8 @@
import { ScrollableElement } from "@/types";
const isBrowser = () => typeof window !== "undefined";
export const handleScrollToTop = (element: ScrollableElement | null) => {
if (!isBrowser()) return;
element?.scrollTo({ top: 0, behavior: "smooth" });
};