Skip to content

Commit

Permalink
Use request animation frame
Browse files Browse the repository at this point in the history
Closes #19
  • Loading branch information
Lazerbeak12345 committed Feb 18, 2022
1 parent 0ad0758 commit 29d4073
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pixelmanipulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
//console.log("play");
if (innerP.mode==="playing") innerP.reset(canvasSizes);
innerP.mode="playing";
innerP.loopint=setInterval(innerP.iterate,1);
innerP.loopint=g.requestAnimationFrame(innerP.iterate);
},
reset:function(canvasSizes) {//reset (and resize) the canvas(es)
// ({}? )
Expand Down Expand Up @@ -386,7 +386,7 @@
},
pause:function() {//pause canvas iterations
innerP.mode="paused";
clearInterval(innerP.loopint);
g.cancelAnimationFrame(innerP.loopint);
},
zoom:function(e ) {//This tells pixelmanipulator where to focus the center of the zoomElm
// ({}?)
Expand Down Expand Up @@ -611,6 +611,8 @@
}
innerP.update();
innerP.onAfterIterate();
if (innerP.mode==="playing")
innerP.loopint=g.requestAnimationFrame(innerP.iterate);
},
updateData:function() {//defines the starting values of the library and is run on `p.reset();`
//console.log("updateData");
Expand Down

0 comments on commit 29d4073

Please sign in to comment.