Capítulo 148 de 411
wrap() places a number (or array index) into a range so it cycles back to the start when it exceeds the maximum, and to the end when it goes below the minimum.
| Signature | Description |
|---|---|
wrap(min, max, valueToWrap) | wrap(array, index) | returns the wrapped value/element immediately |
wrap(min, max) | wrap(array) | returns a reusable wrapping function |
gsap.utils.wrap(["red", "green", "yellow"], 5); // "yellow" (index 5 wraps to 2)