Vadym S. Posted October 8, 2021 Share Posted October 8, 2021 Hi, Is there a way to make snapping not to closest point but to next depending on scroll direction The code: $('.image-shrink-animation').each(function(){ let tl = gsap.timeline({ scrollTrigger: { trigger: $(this).find('.pinned-block'), pin: true, start: "top+=300px center", scrub: false, snap: { snapTo: 1/4, duration: {min: 0.01, max: 0.01} }, end: "+=2000", onUpdate: (function(){ let progress = arguments[0].progress, bgimg = $(this).find('.image-background-wrapper'); console.log('///' + progress) if (progress >= .75) { // do smth } else if (progress >= .5) { // do smth } else if (progress >= .25) { // do smth } else { // do smth } }).bind(this) }, }); }); What I want: if progreese 0.02 and direction = 1 - I want to snap to 0.25, not to 0.0 Link to comment Share on other sites More sharing options...
akapowl Posted October 8, 2021 Share Posted October 8, 2021 Hey @Vadym S. If I understood correctly that behaviour you are looking for is the default since the release of version 3.8.0. So you might just have to update. 3 Link to comment Share on other sites More sharing options...
Vadym S. Posted October 8, 2021 Author Share Posted October 8, 2021 hi @akapowl It sounds like the thing I need. Have to try 3.8 thank you! 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