-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My experience is not showing #21
Comments
Same issue! Can somebody help @ByteGrad |
Resolved it! Add an attribute visible={true} in the VerticalTimelineElement |
Update: somethow I was on next v14, after downgrading to next v 13.4.8 it works as shown in the tutorial @Crazyhaller |
below is another solution proposed on the react-vertical-timeline-component repo |
It worked just fine for me, must have been some other issue for you then I guess |
Hi! To fix this issue add this to your lib/hooks.ts file import { useActiveSectionContext } from "@/context/active-section-context";
import { useEffect } from "react";
import { useInView } from "react-intersection-observer";
import type { SectionName } from "./types";
export function useSectionInView(sectionName: SectionName, threshold = 0.75) {
const { ref, inView } = useInView({
threshold,
});
const { setActiveSection, timeOfLastClick } = useActiveSectionContext();
useEffect(() => {
if (inView && Date.now() - timeOfLastClick > 1000) {
setActiveSection(sectionName);
}
}, [inView, setActiveSection, timeOfLastClick, sectionName]);
return {
ref, inView //ADDING "inView"
};
} and make the following change to your components/experience.tsx file export default function Experience() {
const { ref, inView } = useSectionInView("Experience");
const { theme } = useTheme();
const [isVisible, setIsVisible] = React.useState(false);
React.useEffect(() => {
if (inView) {
setIsVisible(true);
}
}, [inView]);
return (
<section id="experience" ref={ref} className="scroll-mt-28 mb-28 sm:mb-40">
<SectionHeading>My experience</SectionHeading>
<VerticalTimeline lineColor="">
{experiencesData.map((item, index) => (
<React.Fragment key={index}>
<VerticalTimelineElement
visible={isVisible} //THIS WAS ADDED
contentStyle={{
background:
theme === "light" ? "#f3f4f6" : "rgba(255, 255, 255, 0.05)",
boxShadow: "none",
border: "1px solid rgba(0, 0, 0, 0.05)",
textAlign: "left",
padding: "1.3rem 2rem",
}}
... //the rest of the code |
I had mine working with just visible={true} but this broke the SectionInView hook for the Experience element. Following your instructions results in the timeline not displaying for me. |
Did you add section this as well? Can you share some of your code?
|
Hi @Adithya-Rajendran / @drbrunning - There is no need to have a seperate useState and useEffect in Better solution: 👉 Within
However, with this animation will run everytime when Experience section comes to view. To control it, you can use
|
nah your code will have inView to be set true only work when u scroll to the section of experience first time. When i scroll to the same section from a different section the second time what happens is the header slider to the experience will not work because the inView will not change this time and the setActiveSection hook will not be executed as the case in the if here
will not return true the second time i scroll to the section |
All we need to do is return inView in hooks.ts, then set visible={inView} in experience.tsx
|
My experience is not showing but tried everything but still same issue.
Please anyone help me!
The text was updated successfully, but these errors were encountered: