Custom code to add confetti on submitting a form

Just paste this code in your page settings β†’ Custom code β†’ Footer, replace the BLOCKID with your block name, save and preview. Submit your form and let the magic happen :tada:

<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js"></script>
<script>
window.addEventListener('submit-form-success-BLOCKID', (e) => {
    let count = 200;
    let defaults = {origin: { y: 0.7 }};
    function fire(particleRatio, opts) {
        confetti(Object.assign({}, defaults, opts, {
            particleCount: Math.floor(count * particleRatio)
        }));
    }
  fire(0.25, {
    spread: 26,
    startVelocity: 55,
  });
  fire(0.2, {
    spread: 60,
  });
  fire(0.35, {
    spread: 100,
    decay: 0.91,
    scalar: 0.8
  });
  fire(0.1, {
    spread: 120,
    startVelocity: 25,
    decay: 0.92,
    scalar: 1.2
  });
  fire(0.1, {
    spread: 120,
    startVelocity: 45,
  });
});
</script>
5 Likes

Neat! Thank you

Will this code work with on a form block only or any block that has a button of β€œsignificance” warranting a confetti explosion :slight_smile: ?

Thanks for this!!

Also wondering this!

Tested this out, it works with any block aslong as you use the correct event listener!

for my use case it was: update-record-success-BLOCKID

Hope this helps anyone thinking the same thing!