Capítulo 138 de 411

Chapter 138: gsap.utils.mapRange()

Core Idea

mapRange() maps a number's relative position within one range to the equivalent position in another range (like a ratio conversion) — e.g. a 0-200px slider driving movement across a 0-window-width stage.

Reference Tables

SignatureDescription
mapRange(inMin, inMax, outMin, outMax, valueToMap)returns the mapped number immediately
mapRange(inMin, inMax, outMin, outMax)returns a reusable mapping function

Code Examples

gsap.utils.mapRange(-10, 10, 100, 200, 0); // 150

Connects To

  • gsap.utils.normalize(): the same idea with the output range hard-coded to 0-1.