Hello,
I've created a set of 9 animations triggered by pressing keyboard keys [QWE][ASD][ZXC].
My question is about the animation triggered when pressing "C" key (i.e. the 14 small colorful rectangles arriving on the canvas).
These elements are SVG <rect> grouped under a <g id="confettis">.
I defined a function playConfettis() where I randomly move each <rect>. Here is a simplified version of this function :
function playConfettis() {
tl.set(theConfettis, { rotation:0, x:0, y:0 })
.to(theConfetti1, .3, { rotation:rand(-360,360), x:rand(-500,500), y:rand(0,-500) })
.to(theConfetti2, .3, { rotation:rand(-360,360), x:rand(-500,500), y:rand(0,-500) })
...AND SO ON FOR EACH
}
I guess my code is not optimized, but I couldn't figure out how to loop through all those <rect>.
Thank in advance for your suggestions