Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixed various README.md files feat: all components uses a property for init instead of events
- Loading branch information
1 parent
8a6f4a6
commit 86f3038
Showing
28 changed files
with
234 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
{ | ||
"loose": true | ||
} | ||
] | ||
], | ||
"@babel/transform-runtime" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,63 @@ | ||
<script lang="ts"> | ||
import { afterUpdate, createEventDispatcher } from "svelte"; | ||
import { Container, tsParticles } from "tsparticles-engine"; | ||
export let options = {}; | ||
export let url = ""; | ||
export let id = "tsparticles"; | ||
const dispatch = createEventDispatcher(); | ||
const particlesInitEvent = "particlesInit"; | ||
const particlesLoadedEvent = "particlesLoaded"; | ||
let oldId = id; | ||
afterUpdate(() => { | ||
tsParticles.init(); | ||
dispatch(particlesInitEvent, tsParticles); | ||
if (oldId) { | ||
const oldContainer = tsParticles.dom().find((c) => c.id === oldId); | ||
if (oldContainer) { | ||
oldContainer.destroy(); | ||
} | ||
} | ||
if (id) { | ||
const cb = (container) => { | ||
dispatch(particlesLoadedEvent, { | ||
particles: container, | ||
}); | ||
oldId = id; | ||
}; | ||
if (url) { | ||
tsParticles.loadJSON(id, url).then(cb); | ||
} else if (options) { | ||
tsParticles.load(id, options).then(cb); | ||
} else { | ||
console.error("You must specify options or url to load tsParticles"); | ||
} | ||
} else { | ||
dispatch(particlesLoadedEvent, { | ||
particles: undefined, | ||
}); | ||
} | ||
}); | ||
import { afterUpdate, createEventDispatcher } from "svelte"; | ||
import { tsParticles } from "tsparticles-engine"; | ||
export let options = {}; | ||
export let url = ""; | ||
export let id = "tsparticles"; | ||
export let particlesInit; | ||
const dispatch = createEventDispatcher(); | ||
const particlesLoadedEvent = "particlesLoaded"; | ||
let oldId = id; | ||
afterUpdate(async () => { | ||
tsParticles.init(); | ||
if (particlesInit) { | ||
await particlesInit(tsParticles); | ||
} | ||
if (oldId) { | ||
const oldContainer = tsParticles.dom().find((c) => c.id === oldId); | ||
if (oldContainer) { | ||
oldContainer.destroy(); | ||
} | ||
} | ||
if (id) { | ||
const cb = (container) => { | ||
dispatch(particlesLoadedEvent, { | ||
particles: container, | ||
}); | ||
oldId = id; | ||
}; | ||
let container; | ||
if (url) { | ||
container = await tsParticles.loadJSON(id, url); | ||
} else if (options) { | ||
container = await tsParticles.load(id, options); | ||
} else { | ||
console.error("You must specify options or url to load tsParticles"); | ||
return; | ||
} | ||
cb(container); | ||
} else { | ||
dispatch(particlesLoadedEvent, { | ||
particles: undefined, | ||
}); | ||
} | ||
}); | ||
</script> | ||
|
||
<svelte:options accessors={true} /> | ||
<svelte:options accessors={true}/> | ||
|
||
<div {id} /> | ||
<div {id}/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.