PHP 8.2.31
Preview: confetti.js Size: 1.46 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/extendify_old/src/Agent/lib/confetti.js

import confetti from 'canvas-confetti';

let confettiInstance = null;

const ensureConfettiInstance = () => {
	if (confettiInstance) return confettiInstance;

	// Custom canvas to account for height issues
	const canvas = document.createElement('canvas');
	canvas.style.position = 'fixed';
	canvas.style.top = '0';
	canvas.style.left = '0';
	canvas.style.width = '100%';
	canvas.style.height = '100%';
	canvas.style.pointerEvents = 'none';
	canvas.style.zIndex = Number.MAX_SAFE_INTEGER;
	document.body.appendChild(canvas);

	confettiInstance = confetti.create(canvas, {
		disableForReducedMotion: true,
		resize: true,
	});
	return confettiInstance;
};

export const throwSideConfetti = () => {
	const LEFT = {
		count: 200,
		defaults: {
			origin: { y: 0.7, x: 0 },
		},
		shots: [
			{ ratio: 0.25, spread: 26, startVelocity: 55 },
			{ ratio: 0.2, spread: 60 },
			{ ratio: 0.35, spread: 100, decay: 0.91, scalar: 0.8 },
			{ ratio: 0.1, spread: 120, startVelocity: 25, decay: 0.92, scalar: 1.2 },
			{ ratio: 0.1, spread: 120, startVelocity: 45 },
		],
	};
	throwConfetti(LEFT);
	throwConfetti({
		...LEFT,
		defaults: {
			origin: { y: 0.7, x: 1 },
		},
	});
};

const throwConfetti = (config) => {
	const { count = 1, defaults, shots } = config;
	const shoot = ensureConfettiInstance();

	shots.forEach(({ ratio = 1, ...opts }) => {
		shoot({
			...(defaults ?? {}),
			...(opts ?? {}),
			particleCount: Math.floor(count * ratio),
			zIndex: Number.MAX_SAFE_INTEGER,
		});
	});
};

Directory Contents

Dirs: 1 × Files: 14

Name Size Perms Modified Actions
__tests__ DIR
- drwxr-xr-x 2026-04-28 02:40:01
Edit Download
3.01 KB lrw-r--r-- 2026-03-19 23:35:18
Edit Download
1.46 KB lrw-r--r-- 2026-03-19 23:35:18
Edit Download
746 B lrw-r--r-- 2026-02-19 03:27:14
Edit Download
670 B lrw-r--r-- 2026-02-27 04:48:52
Edit Download
1.97 KB lrw-r--r-- 2026-02-27 04:48:52
Edit Download
1.48 KB lrw-r--r-- 2026-02-19 03:27:14
Edit Download
723 B lrw-r--r-- 2025-09-25 20:59:30
Edit Download
640 B lrw-r--r-- 2026-02-19 03:27:14
Edit Download
2.07 KB lrw-r--r-- 2026-02-19 03:27:14
Edit Download
4.91 KB lrw-r--r-- 2026-02-19 03:27:14
Edit Download
461 B lrw-r--r-- 2025-08-27 17:47:28
Edit Download
537 B lrw-r--r-- 2026-04-27 23:36:32
Edit Download
4.72 KB lrw-r--r-- 2025-12-17 19:09:10
Edit Download
420 B lrw-r--r-- 2026-02-27 04:48:52
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).