Share Posted March 10 Hey guys, i m trying to get non-looping value from scrolltrigger update function. The issue i have in the codepen is that it gets me the value every single scrolled pixel. Is there a way how to tell scrollTrigger to return the value only once? Like - ok you reached the section, i ll print your value once (f.e. "1") and then i stop updating until i reach other section i need value from. Any advice is much appreciated! See the Pen wvEpMEr by Buzzworthy (@Buzzworthy) on CodePen Link to comment Share on other sites More sharing options...
Share Posted March 10 Does onEnter instead of onUpdate work? onEnter: check, onEnterBack: check, onToggle could also be useful, depending on your use. onToggle: (self) => { self.isActive ? console.log(self.trigger.dataset.id) : null; }, More info on the callbacks here: https://greensock.com/docs/v3/Plugins/ScrollTrigger 1 Link to comment Share on other sites More sharing options...
Author Share Posted March 10 Thx for the response. I am sorry, I didn t specifiy my issue more thoroughly. What you ve provided works just great for this case, thank you. But imagine we use horizontal scroll with many boxes on the far right (out of the visible window) and you want to detect when the next box is in the view. I m using onUpdate to check the position of the boxes and it can now work with onEnter as far as i know. And onUpdate, of course checks every pixel meaning i ll get that ID xxx times. I need to print the ID only once when the new box is in the view. Any idea @elegantseagulls ? Link to comment Share on other sites More sharing options...
Solution Solution Share Posted March 10 Hi, You should take a look at ScrollTrigger's Container Animation, here is an example: See the Pen WNjaxKp by GreenSock (@GreenSock) on CodePen Hopefully this helps. Happy Tweening! 1 Link to comment Share on other sites More sharing options...
Author Share Posted March 10 I missed this one feature. Thank you Rodrigo!!! 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