particles.js icon indicating copy to clipboard operation
particles.js copied to clipboard

Stopping the Animation from javascript

Open XRyu opened this issue 8 years ago • 7 comments

Hi, Is there any chance to stop the animation using javascript, after it started running? I tried to find the Code inside your Examples GUI, but was unable to find how you disable the animation afterwards..

XRyu avatar Jan 21 '16 17:01 XRyu

Hey @XRyu ,

You can do it by this way:

pJSDom[0].pJS.particles.move.enable = false;

To restart:

pJSDom[0].pJS.particles.move.enable = true;
pJSDom[0].pJS.fn.particlesRefresh();

VincentGarreau avatar Jan 24 '16 14:01 VincentGarreau

If you want to destroy it, see https://github.com/VincentGarreau/particles.js/issues/63#issuecomment-242977446

maxfriedmann avatar Aug 28 '16 14:08 maxfriedmann

Is there a similar method for turning interactivity on and off?

pJSDom[0].pJS.interactivity.events.onclick["enable"] = false;

shawnmitchell avatar Feb 03 '18 05:02 shawnmitchell

Is it possible to pause the movement, and then re-enable it without refreshing?

I want to pause an animation while the user is scrolling.

Swennet avatar Aug 20 '18 12:08 Swennet

@VincentGarreau, thanks so much!

xperiandri avatar Dec 05 '18 19:12 xperiandri

Is it possible to pause the movement, and then re-enable it without refreshing?

I want to pause an animation while the user is scrolling.

pause() {
      this._tempFn = this.pJS.fn.vendors.draw
      window.pJSDom[0].pJS.fn.vendors.draw = () => {
      }
    }
    play() {
      window.pJSDom[0].pJS.fn.vendors.draw = this._tempFn
      window.pJSDom[0].pJS.fn.vendors.draw()
    }

fatlinesofcode avatar Mar 27 '19 09:03 fatlinesofcode

Is it possible to pause the movement, and then re-enable it without refreshing? I want to pause an animation while the user is scrolling.

pause() {
      this._tempFn = this.pJS.fn.vendors.draw
      window.pJSDom[0].pJS.fn.vendors.draw = () => {
      }
    }
    play() {
      window.pJSDom[0].pJS.fn.vendors.draw = this._tempFn
      window.pJSDom[0].pJS.fn.vendors.draw()
    }

It worked for me with corrected second line:

pause() {
      this._tempFn = window.pJSDom[0].pJS.fn.vendors.draw;
      window.pJSDom[0].pJS.fn.vendors.draw = () => {};
}
play() {
      window.pJSDom[0].pJS.fn.vendors.draw = this._tempFn;
      window.pJSDom[0].pJS.fn.vendors.draw();
}

DrNord avatar Aug 30 '21 18:08 DrNord