Skip to content

Commit

Permalink
feat: add animation
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Aug 11, 2024
1 parent 7e7053d commit f986138
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ export const util = (() => {
};

const show = () => {
const duration = 2 * 1000;
const animationEnd = Date.now() + duration;
const defaults = {
startVelocity: 30,
spread: 360,
zIndex: 1057
};

const randomInRange = (min, max) => {
return Math.random() * (max - min) + min;
};

let interval = setInterval(() => {
const timeLeft = animationEnd - Date.now();

if (timeLeft <= 0) {
return clearInterval(interval);
}

const particleCount = 50 * (timeLeft / duration);
confetti({ ...defaults, particleCount, origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 } });
confetti({ ...defaults, particleCount, origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 } });
}, 250);

guest();
opacity('loading', 0.025);
window.scrollTo(0, 0);
Expand Down Expand Up @@ -176,7 +200,7 @@ export const util = (() => {
audio.showButton();

theme.showButtonChangeTheme();
animation();
setTimeout(animation, 1000);
};

const close = () => {
Expand Down

0 comments on commit f986138

Please sign in to comment.