ngrmm Posted November 8, 2022 Share Posted November 8, 2022 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 Link to comment Share on other sites More sharing options...
Solution ngrmm Posted November 8, 2022 Author Solution Share Posted November 8, 2022 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? Link to comment Share on other sites More sharing options...
Rodrigo Posted November 8, 2022 Share Posted November 8, 2022 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! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now