Skip to content

Commit 66b6f11

Browse files
committed
Fix #23
1 parent acbb089 commit 66b6f11

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

lib/clear.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
'use strict';
22

33
module.exports = function() {
4-
cancelAnimationFrame(this.animation);
4+
if (!this.isPaused) {
5+
cancelAnimationFrame(this.animation);
6+
7+
} else {
8+
this.isPaused = false;
9+
}
10+
this.isCleared = true;
511
this.context.clearRect(0, 0, this.x1, this.y1);
6-
};
12+
};

lib/pause.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module.exports = function(state) {
44
var isPausedBecauseNotInView = state === 'isPausedBecauseNotInView';
5+
if (this.isCleared) {return;}
56
if (!isPausedBecauseNotInView) this.isPaused = true;
67
cancelAnimationFrame(this.animation);
78
};

lib/play.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
module.exports = function(state) {
44
var isPausedBecauseNotInView = state === 'isPausedBecauseNotInView';
5-
if (!isPausedBecauseNotInView) this.isPaused = false;
5+
if (!isPausedBecauseNotInView) {
6+
this.isPaused = false;
7+
}
8+
this.isCleared = false;
69
this.animation = requestAnimationFrame(this.animateColors.bind(this));
710
};

0 commit comments

Comments
 (0)