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
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;
}