Thank you, @PointC. Your demo was very helpful. I still have some questions regarding the syntax of gsap.timeline. Here is a sample
pen
Questions:
1. In your code, you write .to("rect", {attr:{stroke:"white"}}, 0);, I deleted attr and wrote it as .to("rect", { stroke:"white"}, 0);. It ended up working exactly the same.
Can you explain what the purpose of attr is? What would be a situation where one would be required to include attr?
EDIT: I double checked and placed attr back in afterwards. Everything worked pretty much the same except for the rotate attribute, which no longer rotates the SVG. I checked the documentation and see nothing beyond the few sentences there. How does one rotate with attr? Is there better documentation available for this plugin?
2. In one of the to()s, I initially used a parameter named stroke-width (copied from the <rect> element), but that caused an error. I then made a guess and turns out the correct word is strokeWidth – it was a good guess, but a guess nonetheless.
Is there a list of attributes where one may find accurate available attribute names?
3. In HTML, the <rect> element's fill is defined as "url(#someID)", referring to the ID of the gradient element. In JavaScript, if I define the #rect's fill attribute as "url(#someID)", the fill color just stays white; or if I define the fill attribute as "#someID", nothing happens.
Is there a convenient way to define to() and from() using fill (or some other attribute, like background) that can encompass the entire gradient at once? Or am I forever stuck with having to minutely change each stopColor attribute at a time?
4. Related to question 3: Because you can't just use "url(#someID)" as a fill in JavaScript, you seem to be stuck with the same gradient structure as you started with.
How do I, for example, (1) animate from a radial to a linear gradient, and back? And (2) what if it's the same structure (linear/radial), but I just want to add additional colors or remove some colors entirely from the lineup?