feat(down-button): added down button func
Now you don't have to scroll all the way down yay
This commit is contained in:
parent
309e0f6b73
commit
542ba32cda
4 changed files with 376 additions and 134 deletions
|
|
@ -3,9 +3,17 @@ import { ArrowDown } from "lucide-react";
|
|||
import { motion } from "motion/react";
|
||||
|
||||
export default function DownButton({ onClick }) {
|
||||
function handleClick(e) {
|
||||
if (onClick) return onClick(e);
|
||||
// default behavior: scroll to bottom of page smoothly
|
||||
const doc = document.documentElement;
|
||||
const top = Math.max(doc.scrollHeight, document.body.scrollHeight);
|
||||
window.scrollTo({ top, behavior: "smooth" });
|
||||
}
|
||||
|
||||
return (
|
||||
<motion.button
|
||||
onClick={onClick}
|
||||
onClick={handleClick}
|
||||
className="bg-gray-700 p-2 rounded-2xl file-input border-2 border-gray-600 size-10"
|
||||
whileHover={{ scale: 1.1 }}
|
||||
whileTap={{ scale: 0.9 }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue