Capítulo 24 de 411

Chapter 24: gsap.parseEase()

Core Idea

gsap.parseEase() converts an ease string into the actual easing function GSAP uses internally, useful when you need to apply an ease's math outside of a tween.

Key Concepts

  • Returns: an easing function.
  • Configurable eases: parametrized strings like "steps(5)" or "elastic(1.2, 0.5)" are parsed into the correctly configured function.
  • Cubic bezier support: if CustomEase is registered, a bezier string (e.g. ".17,.67,.83,.67") parses into a matching custom ease function too.

Code Examples

let ease = gsap.parseEase("power1");
let step = gsap.parseEase("steps(5)");
let elastic = gsap.parseEase("elastic(1.2, 0.5)");
  • What it demonstrates: turning three different ease string formats (simple, parametrized, custom) into callable functions.

Key Takeaways

  1. Useful when you need the raw easing function for custom math (e.g. driving a canvas draw loop manually) rather than a GSAP tween.
  2. Cubic bezier parsing requires CustomEase to be registered first.

Connects To

  • gsap.registerEase(): the counterpart for registering a new named ease, rather than parsing an existing one.