@Rodrigo Sorry, Please i'm back again... I want to understand why the first code works just fine and the second code still shows target not found..
Based on the example you gave me above.. This code works just fine with no issues..
import React, {useRef, useLayoutEffect} from 'react';
import gsap from 'gsap';
import useLoader from '../../hooks/use-loader';
import useAnimatedLetters from '../../hooks/use-animatedletters';
import Bio from './Bio';
const About = () => {
const aboutMe = useRef();
const {loading, loader} = useLoader();
useLayoutEffect(() => {
let ctx;
if (!loading) {
ctx = gsap.context(() => {
gsap
.timeline({
defaults: {opacity: 0, ease: 'back', duration: 1},
})
.from('#about', {ease: 'linear', autoAlpha: 0})
.from('.content > p', {x: -100, stagger: 0.3});
}, aboutMe);
}
return () => ctx && ctx.revert();
}, [loading]);
let string = 'About Me';
const {letters: Heading} = useAnimatedLetters({
strArray: string.split(''),
index: 1,
});
return loading ? (
loader
) : (
<section ref={aboutMe}>
<div
id="about"
className="invisible px-6 lg:ml-16 flex flex-col lg:flex-row items-center justify-center gap-28 lg:40 xl:gap-72 h-full lg:h-screen mb-24 lg:mb-0">
<div>
<h2 className="text-lightMode-100 text-3xl font-bold w-fit mb-6 mt-32 lg:mt-0">
{Heading}
</h2>
<Bio className="content" />
</div>
</div>
</section>
);
};
export default About;
But this code doesn't work.. Only the first element (#contact) in the timeline work.. The rest element in the timeline kept showing target not found...
What may be the issue here... I think i'm doing everything right here and everything should work as expected...
import {useRef, useLayoutEffect} from 'react';
import gsap from 'gsap';
import useLoader from '../../hooks/use-loader';
import Heading from './Heading';
import Form from './Form/Form';
const Contact = () => {
const contactMe = useRef();
const {loading, loader} = useLoader();
useLayoutEffect(() => {
let ctx;
if (!loading) {
ctx = gsap.context(() => {
gsap
.timeline({
defaults: {opacity: 0, ease: 'back', duration: 1},
})
.from('#contact', {ease: 'linear', autoAlpha: 0})
.from('#content > p', {x: -100, stagger: 0.3})
.from('.form div', {x: 100}, '<')
.from('.form > input', {x: 100, stagger: 0.2}, '-=0.8')
.from('.form textarea', {x: 100}, '-=0.8')
.from('.form span', {x: 100}, '-=0.8');
}, contactMe);
}
return () => ctx && ctx.revert();
}, [loading]);
return loading ? (
loader
) : (
<section ref={contactMe}>
<div id="contact" className="invisible">
<div className=" flex flex-col lg:flex-row items-center justify-center h-fit lg:h-screen lg:pl-16 px-8 w-screen gap-20 lg:pb-24 overflow-x-hidden">
<Heading id="content" />
<Form className="form" />
</div>
</div>
</section>
);
};
export default Contact;