Hey everyone!
We wanted to include a confetti effect in our app. We found the following code, which we setup in the Body section of custom code:
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.3.2/dist/confetti.browser.min.js"></script>
<script>
$('#confetti-btn').click(function() {
var end = Date.now() + (8 * 500);
var colors = ['#e6631a', '#72bedd'];
(function frame() {
confetti({
particleCount: 2,
angle: 60,
spread: 100,
origin: { x: 0 },
colors: colors
});
confetti({
particleCount: 2,
angle: 120,
spread: 90,
origin: { x: 1 },
colors: colors
});
if (Date.now() < end) {
requestAnimationFrame(frame);
}
}());
});
</script>
It needs an element with ID, so in WeWeb we put in the ID under HTML attributes “confetti-btn”.
It did not work. We went on to test the same in Webflow and it worked. It was the exact same code and process.
Does someone know how to get the code to work in WeWeb?