tahirw Posted September 29, 2022 Share Posted September 29, 2022 I want to manipulate my img when its going backward/forward for example like this, is this possible? if(yoyo is moving forward){ img.addClass('bg-green') }else{ img.addClass('bg-red') } my current code is like this: const tween = gsap.timeline() tween.to( "#cart1", { duration: 5, ease: "linear", motionPath: { path: "#cart_path", align: "#cart_path", autoRotate: true, alignOrigin: [0.5, 1], }, repeat: -1, yoyo: true, }, "start" ) Thanks in advance Link to comment Share on other sites More sharing options...
Solution akapowl Posted September 29, 2022 Solution Share Posted September 29, 2022 Welcome to the forum @tahirw I'm not sure if there is a dedicated method for that, but what you could do is use the .iteration() to determine wether the yoyo is moving 'forwards' or 'backwards'. // e.g. in an onRepeat callback onRepeat: function() { if (this.iteration() % 2 === 0) { console.log('yoyo is moving backwards') } else { console.log('yoyo is moving forwards') } } See the Pen XWqZwyw by akapowl (@akapowl) on CodePen 1 1 Link to comment Share on other sites More sharing options...
tahirw Posted September 29, 2022 Author Share Posted September 29, 2022 Thank you so much its working 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