Skip to content

Commit

Permalink
Stop rendering when effect is destroyed
Browse files Browse the repository at this point in the history
This fixes issue sirxemic#37
  • Loading branch information
sirxemic committed Jul 14, 2017
1 parent 4da98e1 commit dc41c1c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,17 @@ var Ripples = function (el, options) {
this.visible = true;
this.running = true;
this.inited = true;
this.destroyed = false;

this.setupPointerEvents();

// Init animation
function step() {
that.step();
requestAnimationFrame(step);
if (!that.destroyed) {
that.step();

requestAnimationFrame(step);
}
}

requestAnimationFrame(step);
Expand Down Expand Up @@ -793,6 +797,8 @@ Ripples.prototype = {

this.$canvas.remove();
this.restoreCssBackground();

this.destroyed = true;
},

show: function() {
Expand Down

0 comments on commit dc41c1c

Please sign in to comment.