Skip to content

Commit

Permalink
Merge branch 'matteobruni-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
wufe committed May 22, 2020
2 parents 91226b8 + 091c313 commit e75d2e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "react-particles-js",
"version": "3.2.1",
"version": "3.3.0",
"description": "Reactified particles.js",
"main": "index.js",
"unpkg": "umd/particles.js",
Expand Down Expand Up @@ -35,7 +35,7 @@
},
"dependencies": {
"lodash": "^4.17.11",
"tsparticles": "^1.13.6"
"tsparticles": "^1.14.3"
},
"peerDependencies": {
"react": "^16.0.0"
Expand Down
19 changes: 10 additions & 9 deletions src/Particles.tsx
@@ -1,12 +1,12 @@
import * as React from "react";
import { Component } from "react";
import isEqual from 'lodash/isEqual';
import isEqual from "lodash/isEqual";
import type { IOptions } from "tsparticles/dist/Interfaces/Options/IOptions";
import { Container } from "tsparticles/dist/Classes/Container";
import type { RecursivePartial } from "tsparticles/dist/Types/RecursivePartial";
import { defaultParams } from "./DefaultOptions";
import { Options } from "tsparticles/dist/Classes/Options/Options";
import { tsParticles } from "tsparticles/dist/index";
import { tsParticles } from "tsparticles";

export interface ParticlesProps {
id: string;
Expand Down Expand Up @@ -49,12 +49,13 @@ export default class Particles extends Component<ParticlesProps,
} catch {
return null;
} // SSR
var options = new Options();
const options = new Options();

options.load(defaultParams);
options.load(params);

tsParticles.dom();
tsParticles.init();

const container = new Container(tagId, options);

if (this.props.particlesRef) {
Expand All @@ -69,8 +70,8 @@ export default class Particles extends Component<ParticlesProps,
if (canvas) {
this.destroy();
this.setState({
library: this.buildParticlesLibrary(props.id, props.params)
},
library: this.buildParticlesLibrary(props.id, props.params)
},
() => {
this.loadCanvas(canvas);
}
Expand All @@ -87,8 +88,8 @@ export default class Particles extends Component<ParticlesProps,
loadCanvas(canvas: HTMLCanvasElement) {
if (canvas) {
this.setState({
canvas
},
canvas
},
() => {
const { library } = this.state;

Expand All @@ -104,7 +105,7 @@ export default class Particles extends Component<ParticlesProps,
}

shouldComponentUpdate(nextProps: Readonly<ParticlesProps>) {
return !isEqual(nextProps, this.props);
return !this.state.library || !isEqual(nextProps, this.props);
}

componentDidUpdate() {
Expand Down
17 changes: 11 additions & 6 deletions yarn.lock
Expand Up @@ -3969,18 +3969,23 @@ tsconfig@^6.0.0:
strip-bom "^3.0.0"
strip-json-comments "^2.0.0"

tslib@^1.11.1, tslib@^1.9.0:
tslib@^1.11.2:
version "1.11.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.2.tgz#9c79d83272c9a7aaf166f73915c9667ecdde3cc9"
integrity sha512-tTSkux6IGPnUGUd1XAZHcpu85MOkIl5zX49pO+jfsie3eP0B6pyhOlLXm3cAC6T7s+euSDDUUV+Acop5WmtkVg==

tslib@^1.9.0:
version "1.11.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==

tsparticles@^1.13.6:
version "1.13.6"
resolved "https://registry.yarnpkg.com/tsparticles/-/tsparticles-1.13.6.tgz#f461415d4f670715f8a48393fc8193fb0663afd7"
integrity sha512-ULiKaRNy/3H91A6d56ob7uf03QnVxDS77TVpIGGfoqoyoOU4uOWIF+XtGenrHz9spQu4PO5+mgojXn91sNtDXQ==
tsparticles@^1.14.3:
version "1.14.3"
resolved "https://registry.yarnpkg.com/tsparticles/-/tsparticles-1.14.3.tgz#2ec575d5fd94eff951f77e0a72936d7738283167"
integrity sha512-2nIsKHf2aPZqIb7YjqsIiyoRtkUItTVbTw8q+lantiqP4mpVzAukF7NW49088mrMku6WnBtxjKqlyzsN/jDbcw==
dependencies:
pathseg "^1.2.0"
tslib "^1.11.1"
tslib "^1.11.2"

tty-browserify@0.0.0:
version "0.0.0"
Expand Down

0 comments on commit e75d2e7

Please sign in to comment.