Skip to content

Commit af29a9d

Browse files
committed
feat: play around with confetti animation
1 parent f6dfcc4 commit af29a9d

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
"lint": "vue-cli-service lint"
99
},
1010
"dependencies": {
11+
"canvas-confetti": "^1.3.1",
1112
"core-js": "^3.6.5",
1213
"lodash": "^4.17.20",
13-
"vue": "^3.0.0-0"
14+
"lottie-web": "^5.7.3",
15+
"vue": "^3.0.0-0",
16+
"vue-confetti": "^2.2.1"
1417
},
1518
"devDependencies": {
1619
"@vue/cli-plugin-babel": "~4.5.0",

public/confetti.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/App.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<template>
22
<div id="app">
33
<h1>Hello!</h1>
4-
<CardShuffle />
4+
<Congratulations />
55
</div>
66
</template>
77

88
<script>
9-
import CardShuffle from './components/CardShuffle'
9+
import Congratulations from './components/Congratulations'
1010
1111
export default {
1212
name: 'App',
1313
components: {
14-
CardShuffle
14+
Congratulations
1515
},
1616
data() {
1717
return {

src/components/Congratulations.vue

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<script>
2+
import confetti from 'canvas-confetti'
3+
4+
export default {
5+
methods: {
6+
fireConfetti() {
7+
var end = Date.now() + 3 * 1000
8+
9+
// go Buckeyes!
10+
var colors = ['#34495E', '#41B883']
11+
12+
;(function frame() {
13+
confetti({
14+
particleCount: 2,
15+
angle: 60,
16+
spread: 100,
17+
origin: { x: 0 },
18+
colors: colors
19+
})
20+
confetti({
21+
particleCount: 2,
22+
angle: 120,
23+
spread: 100,
24+
origin: { x: 1 },
25+
colors: colors
26+
})
27+
28+
if (Date.now() < end) {
29+
requestAnimationFrame(frame)
30+
}
31+
})()
32+
}
33+
}
34+
}
35+
</script>
36+
37+
<template>
38+
<div id="confetti">
39+
<h1>Congratulations</h1>
40+
<button @click="fireConfetti">Fire Confetti</button>
41+
</div>
42+
</template>
43+
44+
<style></style>

0 commit comments

Comments
 (0)