Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to destroy a pJS object? #63

Closed
cnjsstong opened this issue Aug 9, 2015 · 7 comments
Closed

How to destroy a pJS object? #63

cnjsstong opened this issue Aug 9, 2015 · 7 comments

Comments

@cnjsstong
Copy link

In IE, it will continue to call raf even after the DOM destroyed. Is there any way to manually destroy a pJS object?

@VincentGarreau
Copy link
Owner

HI @cnjsstong2,

You can destroy the pJS by this way : window.pJSDom[0].pJS.fn.vendors.destroypJS()
I'll check for the IE issue, thanks.
Sorry for my late reply, hope it helps!

@cnjsstong
Copy link
Author

@VincentGarreau Thanks!

@maxfriedmann
Copy link

maxfriedmann commented Aug 28, 2016

If you're in a singe page application and might want to start rendering again (fresh) you have to re-initialize the window.pJSDom array again since .destroypJS removes it completely.

Safest way for me is :

if (window["pJSDom"] instanceof Array && window["pJSDom"].length > 0) {
    for (let i = 0; i < window["pJSDom"].length; i++)
        window["pJSDom"][i].pJS.fn.vendors.destroypJS();
    window["pJSDom"] = [];
}

@RainierMallol
Copy link

RainierMallol commented Apr 11, 2017

In my case, as I'm only using one particle.js object and I'm sure I'll be using only one, I edited @maxfriedmann code to

window.pJSDom[0].pJS.fn.vendors.destroypJS();
window["pJSDom"] = [];

@naturalethic
Copy link

This needs to be in the README

@Dok11
Copy link

Dok11 commented Jul 20, 2018

Seems like destroypJS() destroy of all instances from particlesJs. Not only zero element like in your example

@Moondiidev
Copy link

Wtf is pjsDOM??? there is no mention of it in the readme.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants