Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
don't start another rAF if there's already one
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvonne Yip committed Sep 5, 2014
1 parent dd30755 commit 1a0e819
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions paper-ripple.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,6 @@

wave.startPosition = {x:touchX, y:touchY};

if (!this._loop) {
this._loop = this.animate.bind(this, {
width: width,
height: height
});
}

if (this.classList.contains("recenteringTouch")) {
wave.endPosition = {x: width / 2, y: height / 2};
wave.slideDistance = dist(wave.startPosition, wave.endPosition);
Expand All @@ -352,7 +345,15 @@
wave.wc.style.height = wave.containerSize + 'px';

this.waves.push(wave);
requestAnimationFrame(this._loop);

if (!this._loop) {
this._loop = this.animate.bind(this, {
width: width,
height: height
});
requestAnimationFrame(this._loop);
}
// else there is already a rAF
},

upAction: function() {
Expand Down

0 comments on commit 1a0e819

Please sign in to comment.