Confetti
Een klik op de knop schiet confetti omhoog die draait, fladdert en neerdwarrelt. Klik ergens in het vlak voor een kleiner salvo. Eigen canvas-physics, geen library.
Je aanvraag is binnen.
Zo gebruik je het
- Plak de HTML op de plek waar het onderdeel moet komen.
- Zet de CSS in je stylesheet. Alle klassen hebben een eigen voorvoegsel, dus niets botst met je eigen opmaak.
- Voeg de JavaScript toe en roep init() aan met het element waar de HTML in staat.
<!-- Confetti · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie -->
<div class="jouw-container">
<div class="h3cf">
<canvas class="h3cf-cv" aria-hidden="true"></canvas>
<div class="h3cf-mid">
<p class="h3cf-msg" aria-live="polite">Je aanvraag is binnen.</p>
<button class="h3cf-btn" type="button">Vier het</button>
</div>
</div>
</div>/* Confetti · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie */
/* fonts (Fontshare): switzer@400,600 */
.h3cf{position:relative;width:100%;height:100%;min-height:200px;display:grid;place-items:center;background:#161616;overflow:hidden;cursor:crosshair}
.h3cf-cv{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.h3cf-mid{position:relative;display:grid;justify-items:center;gap:14px;padding:16px;text-align:center}
.h3cf-msg{margin:0;color:#ecebe6;font:400 17px/1.4 Switzer,sans-serif}
.h3cf-btn{border:0;border-radius:4px;padding:14px 26px;background:#F5480F;color:#121212;font:600 16px/1 Switzer,sans-serif;cursor:pointer;transition:transform .15s ease,background .15s ease}
.h3cf-btn:hover{background:#ff6a3a}
.h3cf-btn:active{transform:scale(.96)}
.h3cf-btn:focus-visible{outline:2px solid #fff;outline-offset:3px}// Confetti · © 2026 NedDev BV · NedDev Lab-licentie (gratis gebruik, niet doorverkopen) · neddev.com/nl/lab/gebruik/#licentie
// root = het element waarin de HTML staat
function init(root){
var wrap = root.querySelector('.h3cf'), cv = root.querySelector('.h3cf-cv'), btn = root.querySelector('.h3cf-btn'), msg = root.querySelector('.h3cf-msg');
var ctx = cv.getContext('2d'); if (!ctx) return;
var still = window.matchMedia && matchMedia('(prefers-reduced-motion: reduce)').matches;
var W = 0, H = 0, parts = [], raf = 0, last = 0;
var KLEUR = ['#F5480F', '#ffd23f', '#2ec4b6', '#f6f4ef', '#ff8fab', '#4d9de0', '#9bdc6a'];
function maat() {
var r = wrap.getBoundingClientRect(), d = Math.min(2, window.devicePixelRatio || 1);
W = r.width; H = r.height; cv.width = Math.max(1, Math.round(W * d)); cv.height = Math.max(1, Math.round(H * d));
ctx.setTransform(d, 0, 0, d, 0, 0);
}
maat();
if (window.ResizeObserver) new ResizeObserver(maat).observe(wrap);
function salvo(x, y, n, hoek, spreiding, kracht) {
for (var i = 0; i < n && parts.length < 700; i++) {
var a = hoek + (Math.random() - 0.5) * spreiding, s = kracht * (0.45 + Math.random() * 0.75);
parts.push({
x: x, y: y, vx: still ? 0 : Math.cos(a) * s, vy: still ? 0 : Math.sin(a) * s,
w: 5 + Math.random() * 5, h: 8 + Math.random() * 7, rot: Math.random() * 6.283, vr: (Math.random() - 0.5) * 0.35,
flip: Math.random() * 6.283, vf: 0.08 + Math.random() * 0.18, rond: Math.random() < 0.22,
kleur: KLEUR[(Math.random() * KLEUR.length) | 0], leeftijd: 0, max: still ? 50 : 150 + Math.random() * 90,
sx: still ? x + (Math.random() - 0.5) * 220 : 0, sy: still ? y + (Math.random() - 0.5) * 140 : 0
});
}
if (!raf) { last = 0; raf = requestAnimationFrame(stap); }
}
function stap(t) {
var dt = last ? Math.min(2.5, (t - last) / 16.667) : 1; last = t;
ctx.clearRect(0, 0, W, H);
for (var i = parts.length - 1; i >= 0; i--) {
var p = parts[i];
p.leeftijd += dt;
if (still) { p.x = p.sx; p.y = p.sy; }
else {
p.vy += 0.26 * dt; var rem = Math.pow(0.984, dt); p.vx *= rem; p.vy *= rem;
if (p.vy > 3.2) p.vy = 3.2 + (p.vy - 3.2) * 0.9;
p.x += (p.vx + Math.sin(p.flip) * 0.7) * dt; p.y += p.vy * dt; p.rot += p.vr * dt; p.flip += p.vf * dt;
}
if (p.leeftijd > p.max || p.y > H + 40) { parts.splice(i, 1); continue; }
var a = p.leeftijd > p.max - 35 ? Math.max(0, (p.max - p.leeftijd) / 35) : 1;
ctx.save(); ctx.globalAlpha = a; ctx.translate(p.x, p.y); ctx.rotate(p.rot); ctx.scale(1, Math.cos(p.flip));
ctx.fillStyle = p.kleur;
if (p.rond) { ctx.beginPath(); ctx.arc(0, 0, p.w * 0.55, 0, 6.283); ctx.fill(); }
else ctx.fillRect(-p.w / 2, -p.h / 2, p.w, p.h);
ctx.restore();
}
raf = parts.length ? requestAnimationFrame(stap) : 0;
if (!raf) ctx.clearRect(0, 0, W, H);
}
function punt(el) { var r = el.getBoundingClientRect(), w = wrap.getBoundingClientRect(); return { x: r.left - w.left + r.width / 2, y: r.top - w.top + r.height / 2 }; }
btn.addEventListener('click', function (e) {
e.stopPropagation();
var c = punt(btn), k = Math.max(9, Math.min(15, H / 30));
salvo(c.x, c.y - 10, 90, -Math.PI / 2, 1.5, k);
salvo(0, H, 60, -Math.PI / 3, 0.6, k * 1.15);
salvo(W, H, 60, -Math.PI * 2 / 3, 0.6, k * 1.15);
msg.textContent = 'Gefeliciteerd, we nemen binnen een werkdag contact op.';
});
wrap.addEventListener('click', function (e) {
var w = wrap.getBoundingClientRect();
salvo(e.clientX - w.left, e.clientY - w.top, 45, -Math.PI / 2, 2.6, Math.max(7, Math.min(11, H / 40)));
});
}
init(document.querySelector('.jouw-container'));
Meer uit componenten
Iets gezien dat je mooi vindt?
Zet het in je selectie en stuur hem op. Dan bouwen we je site eromheen, in jouw huisstijl.
Neem contact op →