Fix - Memory leak, animation frame never cancelled
Browse files
assets/scripts/src/overlay.js
CHANGED
|
@@ -141,10 +141,14 @@ export default class Overlay {
|
|
| 141 |
document.body.appendChild(this.overlay);
|
| 142 |
}
|
| 143 |
|
| 144 |
-
//
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
} else {
|
| 149 |
this.document.body.removeChild(this.overlay);
|
| 150 |
}
|
|
|
|
| 141 |
document.body.appendChild(this.overlay);
|
| 142 |
}
|
| 143 |
|
| 144 |
+
// Stage a new animation frame only if the position has not been reached
|
| 145 |
+
// of the alpha has not yet fully reached fully required opacity
|
| 146 |
+
if (
|
| 147 |
+
!this.positionToHighlight.equals(this.highlightedPosition) ||
|
| 148 |
+
this.overlayAlpha.toFixed(2) !== this.opacity.toFixed(2)
|
| 149 |
+
) {
|
| 150 |
+
this.redrawAnimation = this.window.requestAnimationFrame(this.draw);
|
| 151 |
+
}
|
| 152 |
} else {
|
| 153 |
this.document.body.removeChild(this.overlay);
|
| 154 |
}
|
assets/scripts/src/position.js
CHANGED
|
@@ -24,4 +24,11 @@ export default class Position {
|
|
| 24 |
canHighlight() {
|
| 25 |
return this.left < this.right && this.top < this.bottom;
|
| 26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
|
|
|
| 24 |
canHighlight() {
|
| 25 |
return this.left < this.right && this.top < this.bottom;
|
| 26 |
}
|
| 27 |
+
|
| 28 |
+
equals(position) {
|
| 29 |
+
return this.left.toFixed(3) === position.left.toFixed(3) &&
|
| 30 |
+
this.right.toFixed(3) === position.right.toFixed(3) &&
|
| 31 |
+
this.top.toFixed(3) === position.top.toFixed(3) &&
|
| 32 |
+
this.bottom.toFixed(3) === position.bottom.toFixed(3);
|
| 33 |
+
}
|
| 34 |
}
|