Skip to content

Commit

Permalink
fix: fixed bug when using particles groups
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobruni committed Dec 6, 2023
1 parent 69cbb8b commit d8b840d
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 122 deletions.
16 changes: 10 additions & 6 deletions demo/vanilla/public/javascripts/demo.js
@@ -1,4 +1,4 @@
(async function() {
(async () => {
const initParticles = async (engine) => {
await loadAll(engine);
};
Expand Down Expand Up @@ -48,7 +48,7 @@
}
}, 100);

let updateParticles = async function(editor) {
let updateParticles = async (editor) => {
let presetId = localStorage.presetId || "basic";

if (presetId === "divEvents") {
Expand Down Expand Up @@ -148,7 +148,7 @@
tsParticles.domItem(0).refresh();
};

window.addEventListener("load", async function() {
window.addEventListener("load", async () => {
await initParticles(tsParticles);

for (const presetId in tsParticles.configs) {
Expand Down Expand Up @@ -176,10 +176,14 @@

const cmbPresets = document.getElementById("presets");

cmbPresets.onchange = async function() {
localStorage.presetId = this.value;
cmbPresets.onchange = async () => {
localStorage.presetId = cmbPresets.value;

await updateParticles(editor);
try {
await updateParticles(editor);
} catch (e) {
console.error(e);
}
};

if (!localStorage.presetId) {
Expand Down
230 changes: 115 additions & 115 deletions engine/package.json
@@ -1,120 +1,120 @@
{
"name": "@tsparticles/engine",
"version": "3.0.0",
"description": "Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
"homepage": "https://particles.js.org",
"scripts": {
"prettify:ci:schema": "prettier --check ./schema/options.schema.json",
"prettify:schema": "prettier --write ./schema/options.schema.json",
"build": "tsparticles-cli build && pnpm run build:schema",
"build:ci": "tsparticles-cli build --ci && pnpm run build:schema",
"build:schema": "echo ts-json-schema-generator --path 'src/**/*.ts' --type 'IOptions' -f tsconfig.schema.json --additional-properties true --out ./schema/options.schema.json",
"version": "tsparticles-cli build -d && git add package.dist.json",
"postversion": "git push && git push --tags",
"prepack": "pnpm run build",
"release:alpha": "pnpm run version --prerelease --preid alpha",
"release:beta": "pnpm run version --prerelease --preid beta"
"name": "@tsparticles/engine",
"version": "3.0.0",
"description": "Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
"homepage": "https://particles.js.org",
"scripts": {
"prettify:ci:schema": "prettier --check ./schema/options.schema.json",
"prettify:schema": "prettier --write ./schema/options.schema.json",
"build": "tsparticles-cli build && pnpm run build:schema",
"build:ci": "tsparticles-cli build --ci && pnpm run build:schema",
"build:schema": "echo ts-json-schema-generator --path 'src/**/*.ts' --type 'IOptions' -f tsconfig.schema.json --additional-properties true --out ./schema/options.schema.json",
"version": "tsparticles-cli build -d && git add package.dist.json",
"postversion": "git push && git push --tags",
"prepack": "pnpm run build",
"release:alpha": "pnpm run version --prerelease --preid alpha",
"release:beta": "pnpm run version --prerelease --preid beta"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tsparticles/tsparticles.git",
"directory": "engine"
},
"keywords": [
"front-end",
"frontend",
"tsparticles",
"particles.js",
"particlesjs",
"particles",
"particle",
"canvas",
"jsparticles",
"xparticles",
"particles-js",
"particles-bg",
"particles-bg-vue",
"particles-ts",
"particles.ts",
"react-particles-js",
"react-particles.js",
"react-particles",
"react",
"reactjs",
"vue-particles",
"ngx-particles",
"angular-particles",
"particleground",
"vue",
"vuejs",
"preact",
"preactjs",
"jquery",
"angularjs",
"angular",
"typescript",
"javascript",
"animation",
"web",
"html5",
"web-design",
"webdesign",
"css",
"html",
"css3",
"animated",
"background",
"confetti",
"canvas",
"fireworks",
"fireworks-js",
"confetti-js",
"confettijs",
"fireworksjs",
"canvas-confetti"
],
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/tsparticles/tsparticles/issues"
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/matteobruni"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tsparticles/tsparticles.git",
"directory": "engine"
{
"type": "github",
"url": "https://github.com/sponsors/tsparticles"
},
"keywords": [
"front-end",
"frontend",
"tsparticles",
"particles.js",
"particlesjs",
"particles",
"particle",
"canvas",
"jsparticles",
"xparticles",
"particles-js",
"particles-bg",
"particles-bg-vue",
"particles-ts",
"particles.ts",
"react-particles-js",
"react-particles.js",
"react-particles",
"react",
"reactjs",
"vue-particles",
"ngx-particles",
"angular-particles",
"particleground",
"vue",
"vuejs",
"preact",
"preactjs",
"jquery",
"angularjs",
"angular",
"typescript",
"javascript",
"animation",
"web",
"html5",
"web-design",
"webdesign",
"css",
"html",
"css3",
"animated",
"background",
"confetti",
"canvas",
"fireworks",
"fireworks-js",
"confetti-js",
"confettijs",
"fireworksjs",
"canvas-confetti"
],
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/tsparticles/tsparticles/issues"
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/matteobruni"
},
{
"type": "github",
"url": "https://github.com/sponsors/tsparticles"
},
{
"type": "buymeacoffee",
"url": "https://www.buymeacoffee.com/matteobruni"
}
],
"prettier": "@tsparticles/prettier-config",
"files": [
"dist"
],
"sideEffects": false,
"browser": "dist/browser/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"browser": "./dist/browser/index.js",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"umd": "./dist/umd/index.js",
"default": "./dist/cjs/index.js"
},
"./package.json": "./dist/package.json"
},
"publishConfig": {
"access": "public",
"directory": "dist",
"linkDirectory": true
{
"type": "buymeacoffee",
"url": "https://www.buymeacoffee.com/matteobruni"
}
],
"prettier": "@tsparticles/prettier-config",
"files": [
"dist"
],
"sideEffects": false,
"browser": "dist/browser/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"browser": "./dist/browser/index.js",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js",
"umd": "./dist/umd/index.js",
"default": "./dist/cjs/index.js"
},
"./package.json": "./dist/package.json"
},
"publishConfig": {
"access": "public",
"directory": "dist",
"linkDirectory": true
}
}
2 changes: 1 addition & 1 deletion engine/src/Core/Particles.ts
Expand Up @@ -379,7 +379,7 @@ export class Particles {
if (!options.number.density?.enable) {
if (group === undefined) {
this._limit = numberOptions.limit.value;
} else {
} else if (numberOptions.limit) {
this._groupLimits.set(group, numberOptions.limit.value);
}

Expand Down

0 comments on commit d8b840d

Please sign in to comment.