Jump to content
Search Community

ScrollTrigger: onComplete callback

Black Ducas test
Moderator Tag

Recommended Posts

Hi, I'm creating a ScrollTrigger for each cards on my page.

I need to do things after the ScrollTrigger has ended to initialize.

I can't find a callback (like onComplete) to do this. Any help?

 

  cards.forEach(card => {
    ScrollTrigger.create({
      scrollTrigger: {
        trigger: card.querySelector(".title"),
        // onEnter: (self) => { ... }

        // I need something like this:
        onComplete: function() {
          console.log("ScrollTrigger initialized");
          // Doing things
        }
      },
    })
  })

 

 

 

Link to comment
Share on other sites

@OSUblake Hi, no I need a callback that is called after ScrollTrigger.create() is initialized. This is not related to user scrolling or scroll positions.

What I'm doing now is using a seTimeout but it's awful and risky

  setTimeout(function() {
	// Doing things *after* ScrollTrigger.create() is initialized, considering that it finished in 1 second. This is obviously dirty and not precise
  }, 1000);

 

Link to comment
Share on other sites

1 hour ago, Black Ducas said:

@OSUblake Hi, no I need a callback that is called after ScrollTrigger.create() is initialized. This is not related to user scrolling or scroll positions.

 

What do you mean by "initialized"? Initialization happens immediately in .create(), so I'm a bit confused. Perhaps you mean "when the start and end values are finished populating"? That happens on "refresh" events, as Blake pointed out. So yes, you could just listen for that. 

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...