Skip to content

Commit

Permalink
fix(view): improve view disposal by removing resize listener
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinMachado authored and jailln committed Mar 6, 2023
1 parent c83bfcf commit 6f4ec34
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Core/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class View extends THREE.EventDispatcher {

this._frameRequesters = { };

window.addEventListener('resize', () => this.resize(), false);
this._resizeListener = () => this.resize();
window.addEventListener('resize', this._resizeListener, false);

this._changeSources = new Set();

Expand Down Expand Up @@ -258,6 +259,9 @@ class View extends THREE.EventDispatcher {
console.warn('View already disposed');
return;
}

window.removeEventListener('resize', this._resizeListener);

// controls dispose
if (this.controls) {
if (typeof this.controls.dispose === 'function') {
Expand Down

0 comments on commit 6f4ec34

Please sign in to comment.