Jump to content
Search Community

How to add triggers in timeline

JPM82 test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

Is there a way to create triggers for each element in a timeline?  I'm still till learning how to use gsap most efficiently.  I've been using timelines to create my animations, but I want them to trigger at the right time, not just happen one after the other.  Sometimes this is what I want, but when there is a lot of content, I'd like the elements to appear as the user scrolls.  Can I do this within my timeline???  I've been using the relative timing function so far.
Here is an example:

 

const serviceContent = document.querySelector(".service-page-content");

const overviewTl = gsap.timeline({

scrollTrigger: {

trigger: serviceContent,

start: "top center+=50%",

},

defaults: { ease: "", duration: 2 },

});

 

overviewTl

.to(

".services--kicker",

1.5,

{

y: 0,

opacity: 1,

},

"kicker"

)

.to(

".services--list li",

0.5,

{

x: 0,

opacity: 1,

duration: 0.5,

stagger: {

each: 0.1,

onComplete: function () {

gsap.to(this.targets()[0], {

"--bullet-opacity": 1,

"--bullet-translate": 0,

});

},

},

},

"kicker+=1.1"

)

 

.to(

".services--header",

0.5,

{

y: 0,

opacity: 1,

},

"kicker+=.5"

)

.to(

".services--copy",

0.5,

{

y: 0,

opacity: 1,

},

"kicker+=.9"

)

.to(

".badge",

0.4,

{

opacity: 1,

y: 0,

stagger: {

each: 0.1,

},

},

"<"

);

 

Link to comment
Share on other sites

  • Solution

Hi JPM82,

 

If you want different triggers, you probably shouldn't be looking at timeline, at least not a single timeline. That's a common mistake a lot of people make when they get started. Each trigger you want to use should be a different Tween or Timeline.

 

 

 

 

  • Like 1
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...