-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfetti.js
50 lines (45 loc) · 1.42 KB
/
confetti.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute(
"src",
"https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js"
);
document.getElementsByTagName("head")[0].appendChild(script);
function getPosition(event) {
posX = event.pageX;
posY = event.pageY;
}
document.addEventListener("mousemove", getPosition, false);
window.RevealConfetti = function () {
return {
id: "RevealConfetti",
init: function (deck) {
deck.addKeyBinding({ keyCode: 65, key: "A" }, () => {
const config = deck.getConfig();
const options = config.confetti || {};
confetti({
particleCount: options.particleCount,
angle: options.angle,
spread: options.spread,
startVelocity: options.startVelocity,
decay: options.decay,
gravity: options.gravity,
drift: options.drift,
ticks: options.ticks,
colors: options.colors,
shapes: options.shapes,
scalar: options.scalar,
zIndex: options.zIndex,
disableForReducedMotion: options.disableForReducedMotion,
origin: {
x: posX / window.innerWidth,
y: posY / window.innerHeight,
},
});
console.log(`posX: ${posX} | posy: ${posY}`);
console.log(options);
console.log("🎊🎉");
});
},
};
};