Capítulo 141 de 411
random() returns a random number within a range (optionally snapped to an increment), or randomly picks an element from an array.
| Signature | Description |
|---|---|
random(min, max, snapIncrement?, returnFunction?) | random number, optionally snapped; pass returnFunction: true for a reusable randomizer |
random(array) | randomly picks one element from the array |
gsap.utils.random(-100, 100); // random number, no snapping
gsap.utils.random(0, 500, 5); // snapped to nearest multiple of 5
gsap.utils.random(["red", "green", "blue"]); // random array element