Jump to content
Search Community

How to cycle through a set of values

alexb148 test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

I'm not sure of the technical description for what I want to do, but I think I can explain it.

 

Say I'm tweening a property, "x".

 

X must always be a number from 1 to 10.

 

I can tween this easily enough like so:

 

gsap.to(object, 5, {
  x: newValue,
  roundProps: 'x',
});

 

If I want to tween x from "4" to "7" then it loops through fine, essentially going 4, 5, 6, 7.

 

However, if I want to tween from "7" to "4" I don't want it to go 7, 6, 5, 4 - I actually want to go 7, 8, 9, 10, 1, 2, 3, 4.

 

i.e. always counting upwards to a maximum value before starting from the beginning again.

 

Is there a built in way to achieve this in gsap? Thanks!

 

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...