Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use event syntax for particlesLoaded #31

Merged
merged 9 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/nuxt3/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
matteobruni marked this conversation as resolved.
Show resolved Hide resolved
87 changes: 43 additions & 44 deletions apps/nuxt3/app.vue
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
<template>
<div>
<NuxtWelcome />
<vue-particles
id="tsparticles"
:options="options"
:particles-init="particlesInit"
/>
</div>
<div>
<NuxtWelcome />
<vue-particles
id="tsparticles"
:options="options"
:particles-init="particlesInit"
@particles-loaded="particlesLoaded"
/>
</div>
</template>
<script>
<script setup lang="ts">
import { loadFull } from "tsparticles";
import type { ISourceOptions, Container } from "tsparticles-engine";

export default {
name: "NuxtTutorial",
data() {
return {
options: {
background: {
color: "#fff"
},
fullScreen: {
enable: true,
zIndex: -1
},
particles: {
color: {
value: "#000"
},
links: {
color: "#000",
enable: true
},
move: {
enable: true
},
number: {
value: 100
}
}
}
};
const options: ISourceOptions = {
background: {
color: "#fff"
},
fullScreen: {
enable: true,
zIndex: -1
},
particles: {
color: {
value: "#000"
},
methods: {
particlesInit: async (engine) => {
await loadFull(engine);
}
links: {
color: "#000",
enable: true
},
move: {
enable: true
},
number: {
value: 100
}
};
}
}

const particlesInit = async (engine) => {
await loadFull(engine)
}

const particlesLoaded = (container: Container) => {
console.log(container)
}

</script>
<style>
.bg-white {
background: none !important;
background: none !important;
}
</style>
9 changes: 1 addition & 8 deletions apps/nuxt3/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import { defineNuxtConfig } from 'nuxt/config'

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
plugins: [
{
src: '~/plugins/vue3-particles.ts',
mode: 'client',
},
],
})
export default defineNuxtConfig({})
Joepocalyptic marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions apps/nuxt3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"nuxt": "^3.6.5",
"prettier": "^3.0.1",
"tsparticles": "^2.12.0",
"tsparticles-engine": "^2.12.0",
"typescript": "^5.1.6",
"vue": "^3.3.4",
"vue3-particles": "workspace:^",
Expand Down
1 change: 0 additions & 1 deletion apps/nuxt3/shim-vue3-particles.d.ts

This file was deleted.

115 changes: 49 additions & 66 deletions apps/vue3/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,104 +3,87 @@ import type { Container, Engine } from "tsparticles-engine";
import { loadFull } from "tsparticles";
import configs from "tsparticles-demo-configs";

import HelloWorld from "./components/HelloWorld.vue";
import TheWelcome from "./components/TheWelcome.vue";

const options = configs.basic;

const particlesInit = async (engine: Engine) => {
await loadFull(engine);

console.log(engine);
await loadFull(engine);
};

const particlesLoaded = async (container: Container) => {
console.log(container);
console.log(container);
};
</script>

<template>
<header>
<img
alt="Vue logo"
class="logo"
src="./assets/logo.svg"
width="125"
height="125"
/>

<div class="wrapper">
<HelloWorld msg="You did it!" />
</div>
</header>

<main>
<TheWelcome />

<vue-particles id="tsparticles" :options="options" :particlesInit="particlesInit"
:particlesLoaded="particlesLoaded" />
</main>
<main>
<vue-particles
id="tsparticles"
:options="options"
:particles-init="particlesInit"
@particles-loaded="particlesLoaded"
/>
</main>
</template>

<style>
@import "./assets/base.css";

#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
max-width: 1280px;
margin: 0 auto;
padding: 2rem;

font-weight: normal;
font-weight: normal;
}

header {
line-height: 1.5;
line-height: 1.5;
}

.logo {
display: block;
margin: 0 auto 2rem;
display: block;
margin: 0 auto 2rem;
}

a,
.green {
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
}

@media (hover: hover) {
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
}

@media (min-width: 1024px) {
body {
display: flex;
place-items: center;
}

#app {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 0 2rem;
}

header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}

header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}

.logo {
margin: 0 2rem 0 0;
}
body {
display: flex;
place-items: center;
}

#app {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 0 2rem;
}

header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}

header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}

.logo {
margin: 0 2rem 0 0;
}
}
</style>
40 changes: 0 additions & 40 deletions apps/vue3/src/components/HelloWorld.vue

This file was deleted.

Loading
Loading