Small change
This commit is contained in:
+2
-18
@@ -37,25 +37,18 @@ export default function About() {
|
|||||||
{name: "HTML & CSS", level: 70, waveSpeed: "2.7s"},
|
{name: "HTML & CSS", level: 70, waveSpeed: "2.7s"},
|
||||||
];
|
];
|
||||||
|
|
||||||
// Instead of mapping useRef inside a callback, we create one ref for all sections:
|
|
||||||
const sectionRefs = useRef([]);
|
const sectionRefs = useRef([]);
|
||||||
const aboutMeRef = useRef(null);
|
const aboutMeRef = useRef(null);
|
||||||
const scrollContainerRef = useRef(null);
|
const scrollContainerRef = useRef(null);
|
||||||
|
|
||||||
const [currentSection, setCurrentSection] = useState(0);
|
const [currentSection, setCurrentSection] = useState(0);
|
||||||
const [timelineFinished, setTimelineFinished] = useState(false);
|
const [timelineFinished, setTimelineFinished] = useState(false);
|
||||||
|
|
||||||
// Scroll to 'About Me' title and reset timeline on page load
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrentSection(0); // Reset timeline
|
setCurrentSection(0);
|
||||||
setTimelineFinished(false);
|
setTimelineFinished(false);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
aboutMeRef.current?.scrollIntoView({behavior: "smooth", block: "start"});
|
aboutMeRef.current?.scrollIntoView({behavior: "smooth", block: "start"});
|
||||||
}, 100);
|
}, 100);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Handle button navigation
|
|
||||||
const handleButtonClick = (direction) => {
|
const handleButtonClick = (direction) => {
|
||||||
setCurrentSection((prev) => {
|
setCurrentSection((prev) => {
|
||||||
const newSection = Math.max(0, Math.min(prev + direction, timelineData.length - 1));
|
const newSection = Math.max(0, Math.min(prev + direction, timelineData.length - 1));
|
||||||
@@ -64,8 +57,6 @@ export default function About() {
|
|||||||
return newSection;
|
return newSection;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Track scrolling manually and update currentSection
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const observer = new IntersectionObserver(
|
const observer = new IntersectionObserver(
|
||||||
(entries) => {
|
(entries) => {
|
||||||
@@ -81,14 +72,11 @@ export default function About() {
|
|||||||
},
|
},
|
||||||
{threshold: 0.6}
|
{threshold: 0.6}
|
||||||
);
|
);
|
||||||
|
|
||||||
sectionRefs.current.forEach((el) => {
|
sectionRefs.current.forEach((el) => {
|
||||||
if (el) observer.observe(el);
|
if (el) observer.observe(el);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
}, [timelineData.length]);
|
}, [timelineData.length]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{width: "100%", overflowX: "hidden"}}>
|
<div style={{width: "100%", overflowX: "hidden"}}>
|
||||||
{/* About Me Section */}
|
{/* About Me Section */}
|
||||||
@@ -110,7 +98,6 @@ export default function About() {
|
|||||||
Scroll down to learn more about me!
|
Scroll down to learn more about me!
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* Timeline Section */}
|
{/* Timeline Section */}
|
||||||
<section style={{position: "relative", height: "100vh", overflowY: "hidden"}}>
|
<section style={{position: "relative", height: "100vh", overflowY: "hidden"}}>
|
||||||
{currentSection > 0 && (
|
{currentSection > 0 && (
|
||||||
@@ -167,7 +154,6 @@ export default function About() {
|
|||||||
{timelineData.map((item, index) => (
|
{timelineData.map((item, index) => (
|
||||||
<section
|
<section
|
||||||
key={index}
|
key={index}
|
||||||
// Assign each section to sectionRefs.current array
|
|
||||||
ref={(el) => (sectionRefs.current[index] = el)}
|
ref={(el) => (sectionRefs.current[index] = el)}
|
||||||
style={{
|
style={{
|
||||||
flex: "0 0 100%",
|
flex: "0 0 100%",
|
||||||
@@ -187,8 +173,7 @@ export default function About() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
{/* Skills Section*/}
|
||||||
{/* Skills Section with Liquid Progress Bars */}
|
|
||||||
{timelineFinished && (
|
{timelineFinished && (
|
||||||
<section
|
<section
|
||||||
style={{
|
style={{
|
||||||
@@ -202,7 +187,6 @@ export default function About() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<h2 style={{fontSize: "2rem", marginBottom: "2rem"}}>My Skills</h2>
|
<h2 style={{fontSize: "2rem", marginBottom: "2rem"}}>My Skills</h2>
|
||||||
|
|
||||||
<div style={{display: "flex", gap: "2rem"}}>
|
<div style={{display: "flex", gap: "2rem"}}>
|
||||||
{skills.map((skill, index) => (
|
{skills.map((skill, index) => (
|
||||||
<div key={index} style={{textAlign: "center"}}>
|
<div key={index} style={{textAlign: "center"}}>
|
||||||
|
|||||||
Reference in New Issue
Block a user