Jump to content
Search Community

Is there a better code like mine?

Novaliz test
Moderator Tag

Recommended Posts

I have a ScrollTrigger on a p element on which I want to use gsap.to and gsap.from. I wrote it this way:

 

gsap.to(".p-blinker", {
duration: 2,
opacity: 1,
 
scrollTrigger: {
trigger: ".hero",
start: "top 0",
end: "bottom 80%",
// markers: true,
},
});
 
gsap.from(".p-blinker", {
duration: 2,
y: "150",
scrollTrigger: {
trigger: ".hero",
start: "top 0",
end: "bottom 80%",
// markers: true,
},
});

 

I wonder If there is a better solution for this? I needed to write it this way because otherwise the p element would stay 150px higher after the animation.

Link to comment
Share on other sites

There isn't enough detail in your post for us to reasonably help. I'm unsure why you need two tweens for this since they execute simultaneously. It seems like this could be accomplished in one `from` tween or `fromTo` tween without issue.

One optimization is to use `autoAlpha` instead of `opacity`.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...