Returns : *
Returns a number mapped from one range to another. Returns a function that returns mapped numbers if no value (fifth parameter) is given.
Maps a value from one range to another range.
For example, if you have values between -10 and 10 and you want to map them to a range from 0 to 100, so that feeding in 0 would return 50, it’s simple.
If you don’t provide a
value (5th parameter) to map, it’ll return a
function that’s ready to perform mapping accordingly.
//maps 0 in the -10 to 10 range to the same position in the 100 to 200 range
let num = gsap.utils.mapRange(-10, 10, 100, 200, 0); //150
//if we don't provide a value to map, we get a function that's ready to perform mapping accordingly
let mapper = gsap.utils.mapRange(-10, 10, 100, 200); // <- function!
//now we just feed any number into the function we got in the line above, and it'll return the mapped value
let num = mapper(0); //150