tsParticles Fireworks Preset
tsParticles preset for fireworks effects.
Sample
How to use it
CDN / Vanilla JS / jQuery
The first step is installing tsParticles following the instructions for
vanilla javascript in the main project here
Once installed you need one more script to be included in your page (or you can download that
from jsDelivr:
<script src="https://cdn.jsdelivr.net/npm/tsparticles@1/tsparticles.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/tsparticles-preset-fireworks@1/tsparticles.preset.fireworks.min.js"></script>
This script MUST be placed after the tsParticles
one.
Bundle
A bundled script can also be used, this will include every needed plugin needed by the preset.
<script src="https://cdn.jsdelivr.net/npm/tsparticles-preset-fireworks@1/tsparticles.preset.fireworks.bundle.min.js"></script>
Usage
Once the scripts are loaded you can set up tsParticles
like this:
loadFireworksPreset(tsParticles);
tsParticles.load("tsparticles", {
preset: "fireworks",
});
Customization
Important ⚠️
You can override all the options defining the properties like in any standard tsParticles
installation.
tsParticles.load("tsparticles", {
particles: {
shape: {
type: "square",
},
},
preset: "fireworks",
});
Like in the sample above, the circles will be replaced by squares.
React.js / Preact / Inferno
The syntax for React.js
, Preact
and Inferno
is the same.
This sample uses the class component syntax, but you can use hooks as well (if the library supports it).
import Particles from "react-tsparticles";
import { Main } from "tsparticles";
import { loadFireworksPreset } from "tsparticles-preset-fireworks";
export class ParticlesContainer extends React.PureComponent<IProps> {
customInit(main: Main) {
loadFireworksPreset(main);
}
render() {
const options = {
preset: "fireworks",
};
return <Particles options={options} init={this.customInit} />;
}
}
Vue (2.x and 3.x)
The syntax for Vue.js 2.x
and 3.x
is the same
<Particles id="tsparticles" :particlesInit="particlesInit" url="http://foo.bar/particles.json" />
function particlesInit(main: Main) {
loadFireworksPreset(main);
}
Angular
<ng-particles
[id]="id"
[options]="particlesOptions"
(particlesLoaded)="particlesLoaded($event)"
(particlesInit)="particlesInit($event)"
></ng-particles>
function particlesInit(main: Main): void {
loadFireworksPreset(main);
}
Svelte
<Particles
id="tsparticles"
url="http://foo.bar/particles.json"
on:particlesInit="{onParticlesInit}"
/>
let onParticlesInit = (main) => {
loadFireworksPreset(main);
};