attempt to fix visualizer bug with particles going faster over time
This commit is contained in:
parent
30401ccfa6
commit
a88ac265f7
1 changed files with 6 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
//js/visualizer.js
|
||||
import { visualizerSettings } from './storage.js';
|
||||
|
||||
export class Visualizer {
|
||||
constructor(canvas, audio) {
|
||||
this.canvas = canvas;
|
||||
|
|
@ -38,6 +39,7 @@ export class Visualizer {
|
|||
}
|
||||
|
||||
start() {
|
||||
if (this.isActive) return;
|
||||
if (!this.audioContext) this.init();
|
||||
if (!this.analyser) return;
|
||||
|
||||
|
|
@ -59,7 +61,10 @@ export class Visualizer {
|
|||
|
||||
stop() {
|
||||
this.isActive = false;
|
||||
if (this.animationId) cancelAnimationFrame(this.animationId);
|
||||
if (this.animationId) {
|
||||
cancelAnimationFrame(this.animationId);
|
||||
this.animationId = null;
|
||||
}
|
||||
window.removeEventListener('resize', this.resizeBound);
|
||||
|
||||
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
|
|
|
|||
Loading…
Reference in a new issue