186 |
187 |
188 |
189 |
190 |
191 | ```
192 |
193 | ## Potential gotchas
194 |
195 | - Your container must be `overflow: visible` in order to allow elements to fully spread across area.
196 | - If your `floorHeight` is too small, particles may visibly land on the floor instead of disappearing off-screen.
197 |
198 | ## Performance
199 |
200 | This library functions by creating 2 DOM nodes for every single confetti. By default, if the `particlesCount` is set to 150, it will create 300 nodes. This is a lot of nodes. For most devices, these many nodes are not a big issue, but I recommend checking your target devices' performance if you choose to go with a higher number, like 400 or 500.
201 |
202 | Also, after the specified `duration`, all the confetti DOM nodes will be destroyed. This is to free up memory. If you wish to keep them around, set `shouldDestroyAfterDone` to `false`.
203 |
204 | ## License
205 |
206 | MIT License
207 | © [Valgeir Björnsson](https://valgeir.dev/)
208 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | const devPresets = ['@vue/babel-preset-app'];
2 | const buildPresets = [
3 | [
4 | '@babel/preset-env',
5 | // Config for @babel/preset-env
6 | {
7 | // Example: Always transpile optional chaining/nullish coalescing
8 | // include: [
9 | // /(optional-chaining|nullish-coalescing)/
10 | // ],
11 | },
12 | ],
13 | '@babel/preset-typescript',
14 | ];
15 | module.exports = {
16 | presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets),
17 | };
18 |
--------------------------------------------------------------------------------
/build/rollup.config.js:
--------------------------------------------------------------------------------
1 | // rollup.config.js
2 | import fs from 'fs';
3 | import path from 'path';
4 | import vue from 'rollup-plugin-vue';
5 | import alias from '@rollup/plugin-alias';
6 | import commonjs from '@rollup/plugin-commonjs';
7 | import resolve from '@rollup/plugin-node-resolve';
8 | import replace from '@rollup/plugin-replace';
9 | import babel from '@rollup/plugin-babel';
10 | import PostCSS from 'rollup-plugin-postcss';
11 | import { terser } from 'rollup-plugin-terser';
12 | import ttypescript from 'ttypescript';
13 | import typescript from 'rollup-plugin-typescript2';
14 | import minimist from 'minimist';
15 |
16 | // Get browserslist config and remove ie from es build targets
17 | const esbrowserslist = fs.readFileSync('./.browserslistrc')
18 | .toString()
19 | .split('\n')
20 | .filter((entry) => entry && entry.substring(0, 2) !== 'ie');
21 |
22 | // Extract babel preset-env config, to combine with esbrowserslist
23 | const babelPresetEnvConfig = require('../babel.config')
24 | .presets.filter((entry) => entry[0] === '@babel/preset-env')[0][1];
25 |
26 | const argv = minimist(process.argv.slice(2));
27 |
28 | const projectRoot = path.resolve(__dirname, '..');
29 |
30 | const baseConfig = {
31 | input: 'src/entry.ts',
32 | plugins: {
33 | preVue: [
34 | alias({
35 | entries: [
36 | {
37 | find: '@',
38 | replacement: `${path.resolve(projectRoot, 'src')}`,
39 | },
40 | ],
41 | }),
42 | ],
43 | replace: {
44 | 'process.env.NODE_ENV': JSON.stringify('production'),
45 | },
46 | vue: {
47 | },
48 | postVue: [
49 | resolve({
50 | extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
51 | }),
52 | // Process only `
32 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-confetti-explosion",
3 | "version": "1.0.2",
4 | "description": "Confetti explosion in Vue 3 🎉🎊",
5 | "author": {
6 | "name": "Valgeir Björnsson",
7 | "email": "valgeir@hey.com",
8 | "url": "https://github.com/valgeirb"
9 | },
10 | "repository": "github:valgeirb/vue-confetti-explosion",
11 | "keywords": [
12 | "confetti",
13 | "party",
14 | "fun",
15 | "badass",
16 | "badassery",
17 | "vue",
18 | "vue3",
19 | "small",
20 | "tiny",
21 | "performant"
22 | ],
23 | "main": "dist/confetti-explosion.ssr.js",
24 | "browser": "dist/confetti-explosion.esm.js",
25 | "module": "dist/confetti-explosion.esm.js",
26 | "unpkg": "dist/confetti-explosion.min.js",
27 | "types": "dist/types/src/entry.esm.d.ts",
28 | "files": [
29 | "dist/*",
30 | "src/**/*.vue"
31 | ],
32 | "sideEffects": false,
33 | "scripts": {
34 | "serve": "vue-cli-service serve dev/serve.ts",
35 | "prebuild": "rimraf ./dist",
36 | "build": "cross-env NODE_ENV=production rollup --config build/rollup.config.js",
37 | "build:ssr": "cross-env NODE_ENV=production rollup --config build/rollup.config.js --format cjs",
38 | "build:es": "cross-env NODE_ENV=production rollup --config build/rollup.config.js --format es",
39 | "build:unpkg": "cross-env NODE_ENV=production rollup --config build/rollup.config.js --format iife",
40 | "postbuild": "rimraf ./dist/types/dev ./dist/types/src/entry.d.ts"
41 | },
42 | "dependencies": {},
43 | "devDependencies": {
44 | "@babel/core": "^7.14.6",
45 | "@babel/preset-env": "^7.14.7",
46 | "@babel/preset-typescript": "^7.14.5",
47 | "@rollup/plugin-alias": "^3.1.2",
48 | "@rollup/plugin-babel": "^5.3.0",
49 | "@rollup/plugin-commonjs": "^14.0.0",
50 | "@rollup/plugin-node-resolve": "^9.0.0",
51 | "@rollup/plugin-replace": "^2.4.2",
52 | "@vue/cli-plugin-babel": "^4.5.13",
53 | "@vue/cli-plugin-typescript": "^4.5.13",
54 | "@vue/cli-service": "^4.5.13",
55 | "@vue/compiler-sfc": "^3.0.11",
56 | "@zerollup/ts-transform-paths": "^1.7.18",
57 | "cross-env": "^7.0.3",
58 | "minimist": "^1.2.5",
59 | "postcss": "^8.2.10",
60 | "rimraf": "^3.0.2",
61 | "rollup": "^2.52.8",
62 | "rollup-plugin-postcss": "^4.0.0",
63 | "rollup-plugin-terser": "^7.0.2",
64 | "rollup-plugin-vue": "^6.0.0",
65 | "rollup-plugin-typescript2": "^0.30.0",
66 | "ttypescript": "^1.5.12",
67 | "typescript": "^4.0.3",
68 | "vue": "^3.2.22"
69 | },
70 | "peerDependencies": {
71 | "vue": "^3.0.5"
72 | },
73 | "engines": {
74 | "node": ">=12"
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/shims-vue.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.vue' {
2 | import { DefineComponent } from 'vue';
3 |
4 | const Component: DefineComponent<{}, {}, any>;
5 | export default Component;
6 | }
7 |
--------------------------------------------------------------------------------
/src/ConfettiExplosion.vue:
--------------------------------------------------------------------------------
1 |
334 |
335 |