Jump to content
Search Community

ScrollTrigger + TextPlugin

ngrmm

Go to solution Solved by ngrmm,

Recommended Posts

Posted

I would like to change the text of a header element with scrolltrigger.

I store the needed text in data-attributes of the section.

However it works only if I scroll down and only once.

 

Is my toggleActions wrong or do I have to use a timeline?

See the Pen JjZbQjO by ngrmm (@ngrmm) on CodePen.

  • Solution
Posted

UPDATE:

 

I managed to do it with callback function

See the Pen ExRZxvo by ngrmm (@ngrmm) on CodePen.

 

But is it possible to to this only with scrollTrigger?

Posted

Hi,

 

Using restart in the onEnterBack action seems to work as you expect:

sections.forEach((section) => {
  console.log(section.dataset.pname)
  gsap.to("header span", {
    scrollTrigger: {
      trigger: section,
      start: 'top center',
      end: 'bottom center',
      markers: true,
      // Restart on Enter Back
      toggleActions: "restart none restart none",
    },
    text: section.dataset.pname,
    ease: "none",
  });
});

If you are looking for more fine grained control, the using the callbacks, as you already found out, is the way to go.

 

Let us know if you have more questions.

 

Happy Tweening!

  • Like 1

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