From 6d202655b290b9490a94a0e4c220c7baf83f4bdb Mon Sep 17 00:00:00 2001 From: amandeeep02 Date: Wed, 3 Jul 2024 00:19:31 +0530 Subject: [PATCH] Aligned the to-the-top button to center --- src/Components/CardMain.js | 50 +++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/src/Components/CardMain.js b/src/Components/CardMain.js index 6ed22b21..ccbd617f 100644 --- a/src/Components/CardMain.js +++ b/src/Components/CardMain.js @@ -4,7 +4,9 @@ import { Link } from "react-router-dom"; import { features } from "./projects"; function CardMain() { - const [isVisible, setIsVisible] = useState(new Array(features.length).fill(false)); + const [isVisible, setIsVisible] = useState( + new Array(features.length).fill(false) + ); const containerRef = useRef(null); let hideTimeout; @@ -22,7 +24,7 @@ function CardMain() { return newIsVisible; }); }; - + const handleMouseOut = (index) => { hideTimeout = setTimeout(() => { setIsVisible((prevIsVisible) => { @@ -37,21 +39,30 @@ function CardMain() { if (containerRef.current) { containerRef.current.scrollTo({ top: 0, - behavior: 'smooth' + behavior: "smooth", }); } - + window.scrollTo({ top: 0, - behavior: 'smooth' + behavior: "smooth", }); }; return ( -
+
{features.map((project, index) => (
- +

{project.title}

@@ -88,7 +99,7 @@ function CardMain() { Read More - + Source Code
@@ -105,23 +116,28 @@ function CardMain() {
-

- {project.about} -

+

{project.about}

))} - -
+ +
@@ -130,4 +146,4 @@ function CardMain() { ); } -export default CardMain; \ No newline at end of file +export default CardMain;