Created
December 15, 2021 10:27
-
-
Save modster/10e8cad82f7c93ae511140928ebcce8f to your computer and use it in GitHub Desktop.
Confetti
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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