MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / fireConfetti

Function fireConfetti

client/src/utils/fire-confetti.ts:3–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import confetti from 'canvas-confetti';
2
3export const fireConfetti = () => {
4 const count = 200;
5 const defaults = {
6 origin: { y: 0.7 },
7 zIndex: 10000
8 };
9
10 function fire(
11 particleRatio: number,
12 opts: {
13 spread?: number;
14 startVelocity?: number;
15 decay?: number;
16 scalar?: number;
17 }
18 ) {
19 confetti(
20 Object.assign({}, defaults, opts, {
21 particleCount: Math.floor(count * particleRatio)
22 })
23 )?.catch(err => console.log(err));
24 }
25
26 fire(0.25, {
27 spread: 26,
28 startVelocity: 55
29 });
30 fire(0.2, {
31 spread: 60
32 });
33 fire(0.35, {
34 spread: 100,
35 decay: 0.91,
36 scalar: 0.8
37 });
38 fire(0.1, {
39 spread: 120,
40 startVelocity: 25,
41 decay: 0.92,
42 scalar: 1.2
43 });
44 fire(0.1, {
45 spread: 120,
46 startVelocity: 45
47 });
48};

Callers 1

executeChallengeSagaFunction · 0.90

Calls 1

fireFunction · 0.85

Tested by

no test coverage detected