Skip to content

Commit

Permalink
Actually get rid of all references when destroying an instance
Browse files Browse the repository at this point in the history
This makes sure the WebGL context is actually removed.

Fixes issue #63
  • Loading branch information
sirxemic committed Sep 15, 2019
1 parent 42152c4 commit b60368e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,8 @@ var Ripples = function (el, options) {
});

// Auto-resize when window size changes.
$(window).on('resize', function() {
that.updateSize();
});
this.updateSize = this.updateSize.bind(this)
$(window).on('resize', this.updateSize);

// Init rendertargets for ripple data.
this.textures = [];
Expand Down Expand Up @@ -363,7 +362,7 @@ Ripples.prototype = {
.on('mousemove.ripples', function(e) {
dropAtPointer(e);
})
.on('touchmove.ripples, touchstart.ripples', function(e) {
.on('touchmove.ripples touchstart.ripples', function(e) {
var touches = e.originalEvent.changedTouches;
for (var i = 0; i < touches.length; i++) {
dropAtPointer(touches[i]);
Expand Down Expand Up @@ -800,6 +799,11 @@ Ripples.prototype = {
.removeClass('jquery-ripples')
.removeData('ripples');

// Make sure the last used context is garbage-collected
gl = null

$(window).off('resize', this.updateSize);

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

Expand Down

0 comments on commit b60368e

Please sign in to comment.