Skip to content

Commit

Permalink
build: post merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobruni committed Mar 6, 2024
1 parent 80f3f2c commit 89b2eb0
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions components/vue3/src/components/vue-particles.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :id="id"></div>
<div :id="id"></div>
</template>

<script setup lang="ts">
Expand All @@ -11,66 +11,66 @@ export type IParticlesProps = ISourceOptions;
let container: Container | undefined, engine: Engine | undefined;
const props = defineProps<{
id: string;
options?: IParticlesProps;
url?: string;
theme?: string;
id: string;
options?: IParticlesProps;
url?: string;
theme?: string;
}>();
const emit = defineEmits<{
(e: "particlesLoaded", container?: Container): void;
(e: "particlesLoaded", container?: Container): void;
}>();
const initEventHandler = (e: Event) => {
const evt = e as CustomEvent<Engine>;
const evt = e as CustomEvent<Engine>;
engine = evt.detail;
engine = evt.detail;
loadParticles();
loadParticles();
};
addEventListener("particlesInit", initEventHandler);
const loadParticles = async () => {
if (!engine) {
engine = tsParticles;
}
if (!engine) {
engine = tsParticles;
}
container = await engine.load({
id: props.id,
url: props.url,
options: props.options,
});
container = await engine.load({
id: props.id,
url: props.url,
options: props.options,
});
emit("particlesLoaded", container);
emit("particlesLoaded", container);
};
onMounted(() => {
nextTick(() => {
if (!props.id) {
throw new Error("Prop 'id' is required!");
}
nextTick(() => {
if (!props.id) {
throw new Error("Prop 'id' is required!");
}
loadParticles();
});
loadParticles();
});
});
onUnmounted(() => {
if (!container) {
return;
}
if (!container) {
return;
}
container.destroy();
container.destroy();
container = undefined;
container = undefined;
removeEventListener("particlesInit", initEventHandler);
removeEventListener("particlesInit", initEventHandler);
});
watch(
() => props.theme,
() => {
container?.loadTheme(props.theme);
container?.loadTheme(props.theme);
},
{ immediate: true, deep: true },
);
Expand Down

0 comments on commit 89b2eb0

Please sign in to comment.