Share Posted August 20, 2020 I am having a little trouble working a variable into an object name. For instance, suppose I have 30 boxes named box1alpha, box2alpha, box3alpha, etc. I have tried to drop a variable in the middle of an object name and it seems to work the first time but when the variable is changed it doesn't. In the codepen - I am expecting each box to move down with each click as the num variable is incremented. How can I get the animation to read the new variable on subsequent plays? See the Pen mdPrNrz?editors=1111 by Arelwynn (@Arelwynn) on CodePen Link to comment Share on other sites More sharing options...
Share Posted August 20, 2020 You can't change the target of a tween like that. It's best to create a new tween/timeline when you want to animate a a new target. 2 Link to comment Share on other sites More sharing options...
Author Share Posted August 20, 2020 Bummer - this method would have worked much slicker than having 30+ tweens. Link to comment Share on other sites More sharing options...
Share Posted August 20, 2020 You can just use a functions and loops to do the heavy lifting for you. You can even use a global vars object of values and pass it to the tweens if that works in your situation. If you want to share more, maybe we can point you in the right direction. Happy tweening. 1 Link to comment Share on other sites More sharing options...
Share Posted August 20, 2020 Making use of some gsap utils. See the Pen f4218d74342b41f7c984c0cc4ba4ce2b by osublake (@osublake) on CodePen 6 1 Link to comment Share on other sites More sharing options...
Share Posted August 20, 2020 Look at Blake getting all fancy today. 1 Link to comment Share on other sites More sharing options...
Author Share Posted August 20, 2020 😮 Nice! Link to comment Share on other sites More sharing options...
Share Posted August 20, 2020 9 minutes ago, PointC said: Look at Blake getting all fancy today. It's get fancy with gsap week. 2 3 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