Skip to content

Commit fccba7d

Browse files
committed
Upgraded the confetti to fireworks
1 parent 0f7b7ff commit fccba7d

File tree

1 file changed

+45
-23
lines changed

1 file changed

+45
-23
lines changed

apps/webapp/app/components/helpContent/HelpContentText.tsx

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,54 @@ export function HowToSetupYourProject() {
5757
if (events !== null) {
5858
// This uses https://www.npmjs.com/package/canvas-confetti
5959
if ("confetti" in window && typeof window.confetti !== "undefined") {
60-
var duration = 2.5 * 1000;
61-
var end = Date.now() + duration;
60+
const duration = 3.5 * 1000;
61+
const animationEnd = Date.now() + duration;
62+
const defaults = {
63+
startVelocity: 30,
64+
spread: 360,
65+
ticks: 60,
66+
zIndex: 0,
67+
colors: [
68+
"#E7FF52",
69+
"#41FF54",
70+
"rgb(245 158 11)",
71+
"rgb(22 163 74)",
72+
"rgb(37 99 235)",
73+
"rgb(67 56 202)",
74+
"rgb(219 39 119)",
75+
"rgb(225 29 72)",
76+
"rgb(217 70 239)",
77+
],
78+
};
79+
// @ts-ignore
80+
function randomInRange(min, max) {
81+
return Math.random() * (max - min) + min;
82+
}
83+
// @ts-ignore
84+
const interval = setInterval(function () {
85+
const timeLeft = animationEnd - Date.now();
86+
87+
if (timeLeft <= 0) {
88+
return clearInterval(interval);
89+
}
6290

63-
(function frame() {
64-
// launch a few confetti from the left edge
91+
const particleCount = 50 * (timeLeft / duration);
92+
// since particles fall down, start a bit higher than random
6593
// @ts-ignore
66-
window.confetti({
67-
particleCount: 7,
68-
angle: 60,
69-
spread: 55,
70-
origin: { x: 0 },
71-
});
72-
// and launch a few from the right edge
94+
window.confetti(
95+
Object.assign({}, defaults, {
96+
particleCount,
97+
origin: { x: randomInRange(0.1, 0.4), y: Math.random() - 0.2 },
98+
})
99+
);
73100
// @ts-ignore
74-
window.confetti({
75-
particleCount: 7,
76-
angle: 120,
77-
spread: 55,
78-
origin: { x: 1 },
79-
});
80-
81-
// keep going until we are out of time
82-
if (Date.now() < end) {
83-
requestAnimationFrame(frame);
84-
}
85-
})();
101+
window.confetti(
102+
Object.assign({}, defaults, {
103+
particleCount,
104+
origin: { x: randomInRange(0.6, 0.9), y: Math.random() - 0.2 },
105+
})
106+
);
107+
}, 250);
86108
}
87109

88110
revalidator.revalidate();

0 commit comments

Comments
 (0)