Skip to content

Commit 706b74c

Browse files
authored
Merge pull request #55 from SAG-Storck/main
Fix particles beeing loaded before component ist mounted on navigation in SvelteKit
2 parents d760dcd + feeb2d3 commit 706b74c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/svelte/src/lib/Particles.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
let cssClass = '';
1010
export { cssClass as class };
1111
let canStart = false;
12+
let mounted = false;
1213
1314
let style = '';
1415
export { style };
@@ -45,13 +46,14 @@
4546
});
4647
4748
onMount(() => {
49+
mounted = true;
4850
void loadParticles();
4951
});
5052
5153
async function loadParticles(): Promise<void> {
5254
destroyOldContainer();
5355
54-
if (!canStart) {
56+
if (!canStart || !mounted) {
5557
return;
5658
}
5759

0 commit comments

Comments
 (0)