Skip to content

Commit

Permalink
Merge pull request #38 from gnuletik/master
Browse files Browse the repository at this point in the history
fix(canvas): force garbage collection on Safari
  • Loading branch information
bibixx authored Dec 30, 2020
2 parents bf70605 + 38c5535 commit 093f4ba
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,19 @@ export default class AnimateCC extends React.Component {

componentWillUnmount() {
const { error } = this.state;
if (error) {
return;
}

if (!error) {
window.removeEventListener("resize", this.resizeCanvas);
this.stopAnimation();
// Force garbage collection on Safari
// https://bugs.webkit.org/show_bug.cgi?id=195325
if (this.canvas) {
this.canvas.height = 0;
this.canvas.width = 0;
}

window.removeEventListener("resize", this.resizeCanvas);
this.stopAnimation();
}

onAnimationReady = () => {
Expand Down

0 comments on commit 093f4ba

Please sign in to comment.