MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / updateParticles

Function updateParticles

assets/confetti_js/confetti.js:188–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

186 }
187
188 function updateParticles() {
189 var width = window.innerWidth;
190 var height = window.innerHeight;
191 var particle;
192 waveAngle += 0.01;
193 for (var i = 0; i < particles.length; i++) {
194 particle = particles[i];
195 if (!streamingConfetti && particle.y < -15)
196 particle.y = height + 100;
197 else {
198 particle.tiltAngle += particle.tiltAngleIncrement;
199 particle.x += Math.sin(waveAngle) - 0.5;
200 particle.y += (Math.cos(waveAngle) + particle.diameter + confetti.speed) * 0.5;
201 particle.tilt = Math.sin(particle.tiltAngle) * 15;
202 }
203 if (particle.x > width + 20 || particle.x < -20 || particle.y > height) {
204 if (streamingConfetti && particles.length <= confetti.maxCount)
205 resetParticle(particle, width, height);
206 else {
207 particles.splice(i, 1);
208 i--;
209 }
210 }
211 }
212 }
213})();

Callers 1

runAnimationFunction · 0.70

Calls 1

resetParticleFunction · 0.70

Tested by

no test coverage detected