Skip to content

Commit 8e7ed34

Browse files
authored
Merge pull request #31 from Joepocalyptic/main
fix: use event syntax for particlesLoaded
2 parents 8d4b6f2 + e537e3a commit 8e7ed34

File tree

22 files changed

+178
-583
lines changed

22 files changed

+178
-583
lines changed

apps/nuxt3/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

apps/nuxt3/app.vue

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,54 @@
11
<template>
2-
<div>
3-
<NuxtWelcome />
4-
<vue-particles
5-
id="tsparticles"
6-
:options="options"
7-
:particles-init="particlesInit"
8-
/>
9-
</div>
2+
<div>
3+
<NuxtWelcome />
4+
<vue-particles
5+
id="tsparticles"
6+
:options="options"
7+
:particles-init="particlesInit"
8+
@particles-loaded="particlesLoaded"
9+
/>
10+
</div>
1011
</template>
11-
<script>
12+
<script setup lang="ts">
1213
import { loadFull } from "tsparticles";
14+
import type { ISourceOptions, Container } from "tsparticles-engine";
1315
14-
export default {
15-
name: "NuxtTutorial",
16-
data() {
17-
return {
18-
options: {
19-
background: {
20-
color: "#fff"
21-
},
22-
fullScreen: {
23-
enable: true,
24-
zIndex: -1
25-
},
26-
particles: {
27-
color: {
28-
value: "#000"
29-
},
30-
links: {
31-
color: "#000",
32-
enable: true
33-
},
34-
move: {
35-
enable: true
36-
},
37-
number: {
38-
value: 100
39-
}
40-
}
41-
}
42-
};
16+
const options: ISourceOptions = {
17+
background: {
18+
color: "#fff"
19+
},
20+
fullScreen: {
21+
enable: true,
22+
zIndex: -1
23+
},
24+
particles: {
25+
color: {
26+
value: "#000"
4327
},
44-
methods: {
45-
particlesInit: async (engine) => {
46-
await loadFull(engine);
47-
}
28+
links: {
29+
color: "#000",
30+
enable: true
31+
},
32+
move: {
33+
enable: true
34+
},
35+
number: {
36+
value: 100
4837
}
49-
};
38+
}
39+
}
40+
41+
const particlesInit = async (engine) => {
42+
await loadFull(engine)
43+
}
44+
45+
const particlesLoaded = (container: Container) => {
46+
console.log(container)
47+
}
48+
5049
</script>
5150
<style>
5251
.bg-white {
53-
background: none !important;
52+
background: none !important;
5453
}
5554
</style>

apps/nuxt3/nuxt.config.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
import { defineNuxtConfig } from 'nuxt/config'
22

33
// https://v3.nuxtjs.org/api/configuration/nuxt.config
4-
export default defineNuxtConfig({
5-
plugins: [
6-
{
7-
src: '~/plugins/vue3-particles.ts',
8-
mode: 'client',
9-
},
10-
],
11-
})
4+
export default defineNuxtConfig({})

apps/nuxt3/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"nuxt": "^3.6.5",
3636
"prettier": "^3.0.1",
3737
"tsparticles": "^2.12.0",
38+
"tsparticles-engine": "^2.12.0",
3839
"typescript": "^5.1.6",
3940
"vue": "^3.3.4",
4041
"vue3-particles": "workspace:^",
File renamed without changes.

apps/nuxt3/shim-vue3-particles.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/vue3/src/App.vue

Lines changed: 49 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,104 +3,87 @@ import type { Container, Engine } from "tsparticles-engine";
33
import { loadFull } from "tsparticles";
44
import configs from "tsparticles-demo-configs";
55
6-
import HelloWorld from "./components/HelloWorld.vue";
7-
import TheWelcome from "./components/TheWelcome.vue";
8-
96
const options = configs.basic;
107
118
const particlesInit = async (engine: Engine) => {
12-
await loadFull(engine);
13-
14-
console.log(engine);
9+
await loadFull(engine);
1510
};
1611
1712
const particlesLoaded = async (container: Container) => {
18-
console.log(container);
13+
console.log(container);
1914
};
2015
</script>
2116

2217
<template>
23-
<header>
24-
<img
25-
alt="Vue logo"
26-
class="logo"
27-
src="./assets/logo.svg"
28-
width="125"
29-
height="125"
30-
/>
31-
32-
<div class="wrapper">
33-
<HelloWorld msg="You did it!" />
34-
</div>
35-
</header>
36-
37-
<main>
38-
<TheWelcome />
39-
40-
<vue-particles id="tsparticles" :options="options" :particlesInit="particlesInit"
41-
:particlesLoaded="particlesLoaded" />
42-
</main>
18+
<main>
19+
<vue-particles
20+
id="tsparticles"
21+
:options="options"
22+
:particles-init="particlesInit"
23+
@particles-loaded="particlesLoaded"
24+
/>
25+
</main>
4326
</template>
4427

4528
<style>
4629
@import "./assets/base.css";
4730
4831
#app {
49-
max-width: 1280px;
50-
margin: 0 auto;
51-
padding: 2rem;
32+
max-width: 1280px;
33+
margin: 0 auto;
34+
padding: 2rem;
5235
53-
font-weight: normal;
36+
font-weight: normal;
5437
}
5538
5639
header {
57-
line-height: 1.5;
40+
line-height: 1.5;
5841
}
5942
6043
.logo {
61-
display: block;
62-
margin: 0 auto 2rem;
44+
display: block;
45+
margin: 0 auto 2rem;
6346
}
6447
6548
a,
6649
.green {
67-
text-decoration: none;
68-
color: hsla(160, 100%, 37%, 1);
69-
transition: 0.4s;
50+
text-decoration: none;
51+
color: hsla(160, 100%, 37%, 1);
52+
transition: 0.4s;
7053
}
7154
7255
@media (hover: hover) {
73-
a:hover {
74-
background-color: hsla(160, 100%, 37%, 0.2);
75-
}
56+
a:hover {
57+
background-color: hsla(160, 100%, 37%, 0.2);
58+
}
7659
}
7760
7861
@media (min-width: 1024px) {
79-
body {
80-
display: flex;
81-
place-items: center;
82-
}
83-
84-
#app {
85-
display: grid;
86-
grid-template-columns: 1fr 1fr;
87-
padding: 0 2rem;
88-
}
89-
90-
header {
91-
display: flex;
92-
place-items: center;
93-
padding-right: calc(var(--section-gap) / 2);
94-
}
95-
96-
header .wrapper {
97-
display: flex;
98-
place-items: flex-start;
99-
flex-wrap: wrap;
100-
}
101-
102-
.logo {
103-
margin: 0 2rem 0 0;
104-
}
62+
body {
63+
display: flex;
64+
place-items: center;
65+
}
66+
67+
#app {
68+
display: grid;
69+
grid-template-columns: 1fr 1fr;
70+
padding: 0 2rem;
71+
}
72+
73+
header {
74+
display: flex;
75+
place-items: center;
76+
padding-right: calc(var(--section-gap) / 2);
77+
}
78+
79+
header .wrapper {
80+
display: flex;
81+
place-items: flex-start;
82+
flex-wrap: wrap;
83+
}
84+
85+
.logo {
86+
margin: 0 2rem 0 0;
87+
}
10588
}
10689
</style>

apps/vue3/src/components/HelloWorld.vue

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)