Package Exports
- tsparticles
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tsparticles) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
tsParticles Bubbles Preset
tsParticles preset for colored bubbles coming from the bottom of the screen on a white background.
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"></script>
<script src="https://cdn.jsdelivr.net/npm/tsparticles-preset-bubbles"></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-bubbles/dist/tsparticles.preset.bubbles.bundle.min.js"></script>
Usage
Once the scripts are loaded you can set up tsParticles
like this:
loadBubblesPreset(tsParticles);
tsParticles.load("tsparticles", {
preset: "bubbles",
});
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: "bubbles",
});
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-engine";
import { loadBubblesPreset } from "tsparticles-preset-bubbles";
export class ParticlesContainer extends React.PureComponent<IProps> {
// this customizes the component tsParticles installation
customInit(main: Main) {
// this adds the preset to tsParticles, you can safely use the
loadBubblesPreset(main);
}
render() {
const options = {
preset: "bubbles",
};
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) {
loadBubblesPreset(main);
}
Angular
<ng-particles
[id]="id"
[options]="particlesOptions"
(particlesLoaded)="particlesLoaded($event)"
(particlesInit)="particlesInit($event)"
></ng-particles>
function particlesInit(main: Main): void {
loadBubblesPreset(main);
}
Svelte
<Particles
id="tsparticles"
url="http://foo.bar/particles.json"
on:particlesInit="{onParticlesInit}"
/>
let onParticlesInit = (main) => {
loadBubblesPreset(main);
};