Capítulo 162 de 411
A helper that converts a keyword backgroundSize value like "cover" or "contain" into its equivalent pixel dimensions for the current element, because GSAP can only tween between numeric values, not CSS keywords.
backgroundImage/backgroundSize and, if a native width/height isn't supplied, loads the image to detect its natural size.size (target size/keyword to convert), nativeWidth, nativeHeight — supplying the native dimensions avoids an extra image load.// simple: returns current backgroundSize in px
bgSize(".class");
// advanced: converts "cover" to px assuming a known native image size
bgSize(".class", { size: "cover", nativeWidth: 600, nativeHeight: 400 });
nativeWidth/nativeHeight avoids a potentially slow extra image load to detect natural size.backgroundSize keywords aren't numeric — plain px/percentage values tween directly without this helper.