Fixed dots memory leak

This commit is contained in:
Lucas
2026-03-16 16:37:30 +10:00
parent 1f0cb60a4f
commit 4704c88627

View File

@@ -130,10 +130,17 @@ function handleMouseMove(e) {
// Animation // Animation
function drawIfMouseMoving() { function drawIfMouseMoving() {
if (!mouseMoving) return; if (!mouseMoving){
if (dots.length === 0) { if (dots.length > 0 && dots[dots.length - 1] === undefined) {
dots[0] = new Dot(0, mouseX, mouseY); dots = [];
dots[0].draw(); console.log("Cleaning dots")
}
return;
};
if (dots.length === 0 || ! getPreviousDot(dots.length, 1)) {
const seedDot = new Dot(0, mouseX, mouseY);
dots.push(seedDot);
return; return;
} }