This commit is contained in:
quantulr
2023-11-03 17:25:10 +08:00
parent 2423f8c2e8
commit b6a722fa79
62 changed files with 415 additions and 260 deletions

View File

@ -1,14 +1,28 @@
"use client";
import backTop from "@/app/assets/backtop.png";
import Image from "next/image";
// import { useScroll } from "ahooks";
import { useScroll } from "ahooks";
/**
* 返回到顶部
* @constructor
*/
const BackToTop = () => {
// const position = useScroll();
const position = useScroll();
return (
<div className={`fixed bottom-4 right-10 w-[50px] h-[50px]`}>
<div
className={`fixed bottom-4 right-10 h-[50px] w-[50px] overflow-hidden`}
>
<Image
className={"w-full h-full cursor-pointer"}
onClick={() => {
window.scroll({
top: 0,
behavior: "smooth",
});
}}
className={`${
(position?.top ?? 0) > 100 ? "top-0" : "top-full"
} absolute left-0 h-full w-full cursor-pointer transition-all`}
src={backTop}
alt={""}
/>