Hi all,
Getting my feet wet with GSAP for the first time and the results look promising
BUT...
I am bumping into an opacity issue.
I have a shadow-png positioned underneath another image (phone).
What I am trying to do is, when the phone moves up, I want the shadow png to become more transparant. But, when that animation starts, the opacity is immediately 0, instead of animating to 0.
The animations here are:
- a laptop slides in from the left
- a phone slides in from the right
- the phone's shadow slides in as well
- when the scrolling begins, the phone needs to move up
- and the shadow needs to become more transparent.
And that last animation immediately starts at 0.
What am I doing wrong?
Thanks for the advice!
useLayoutEffect(() => {
const laptop_animation = tl.from(sectionone_laptop_ref.current, {
left: "-200px",
opacity: 0,
delay: 1,
});
const phone_animation = tl.from(
sectionone_phone_ref.current,
{
left: "480px",
opacity: 0,
},
"<",
);
const shadow_animation = tl.from(
sectionone_phone_shadow_ref.current,
{
left: "480px",
opacity: 0,
},
"<",
);
const parallax_animation_phone = tl.to(sectionone_phone_ref.current, {
top: "0px",
scrollTrigger: {
trigger: "#page",
start: "top top",
end: "+=100%",
scrub: true,
},
});
const parallax_animation_phone_shadow = tl.to(
sectionone_phone_shadow_ref.current,
{
opacity: 0,
scrollTrigger: {
trigger: "#sectionOne",
start: "31% 30%",
scrub: true,
markers: true,
},
},
);
return () => {
phone_animation.kill();
shadow_animation.kill();
laptop_animation.kill();
parallax_animation_phone.kill();
parallax_animation_phone_shadow.kill();
};
}, [
sectionone_laptop_ref,
sectionone_phone_ref,
sectionone_phone_shadow_ref,
]);