Fixed dots memory leak
This commit is contained in:
@@ -130,10 +130,17 @@ function handleMouseMove(e) {
|
||||
|
||||
// Animation
|
||||
function drawIfMouseMoving() {
|
||||
if (!mouseMoving) return;
|
||||
if (dots.length === 0) {
|
||||
dots[0] = new Dot(0, mouseX, mouseY);
|
||||
dots[0].draw();
|
||||
if (!mouseMoving){
|
||||
if (dots.length > 0 && dots[dots.length - 1] === undefined) {
|
||||
dots = [];
|
||||
console.log("Cleaning dots")
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
if (dots.length === 0 || ! getPreviousDot(dots.length, 1)) {
|
||||
const seedDot = new Dot(0, mouseX, mouseY);
|
||||
dots.push(seedDot);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user