Fixed dots memory leak
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user