Capítulo 189 de 411

Chapter 189: CSSRulePlugin.getRule() (deprecated)

Core Idea

Static method that returns a reference to a stylesheet rule object (by CSS selector) that can then be fed as a GSAP tween target, since deprecated CSSRulePlugin animated rules rather than individual elements.

Code Examples

// deprecated pattern — prefer native CSS variable animation instead
var rule = CSSRulePlugin.getRule(".myClass::before");
gsap.to(rule, { cssRule: { color: "blue" }, duration: 1 });
  • What it demonstrates: obtaining a rule reference for a selector that JS can't otherwise touch (like a ::before pseudo-element), then tweening its cssRule properties.

Anti-patterns

  • New projects using this instead of CSS custom properties: this whole plugin is deprecated; prefer gsap.to(el, {"--my-var": value}).

Connects To

  • CSSRulePlugin (previous chapter): overview and the recommended modern replacement.