Skip to content

Instantly share code, notes, and snippets.

@modster
Created December 15, 2021 10:27
Show Gist options
  • Save modster/10e8cad82f7c93ae511140928ebcce8f to your computer and use it in GitHub Desktop.
Save modster/10e8cad82f7c93ae511140928ebcce8f to your computer and use it in GitHub Desktop.
Confetti
// We can import code dynamically, top level await is supported.
const {default: Confetti} = await import('https://cdn.skypack.dev/canvas-confetti');
function fireConfetti(event) {
const x = event.clientX / document.body.clientWidth;
const y = event.clientY / document.body.clientHeight;
Confetti({origin: {x, y}});
}
// lit templating is built-in
html`<button @click=${fireConfetti}>Fire Confetti 🎉</button>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment