10 years ago by Joncom
Debugging draw calls is difficult when you can't see the effect of each draw. This seems to be the case when using Chrome DevTools and breakpoints with Impact as-is. You can draw to the canvas, but you won't see the change for a while. If we disable RequestAnimationFrame though, changes to canvas are instant.
Modifying the library directly is not ideal however. An option to switch modes would be nice. Or perhaps default to one mode when the debug module is loaded, and otherwise the other...
/* impact.js */ /*if( window.requestAnimationFrame ) { var next = 1, anims = {}; window.ig.setAnimation = function( callback, element ) { var current = next++; anims[current] = true; var animate = function() { if( !anims[current] ) { return; } // deleted? window.requestAnimationFrame( animate, element ); callback(); }; window.requestAnimationFrame( animate, element ); return current; }; window.ig.clearAnimation = function( id ) { delete anims[id]; }; } // [set/clear]Interval fallback else {*/ window.ig.setAnimation = function( callback, element ) { return window.setInterval( callback, 1000/60 ); }; window.ig.clearAnimation = function( id ) { window.clearInterval( id ); }; //}
Modifying the library directly is not ideal however. An option to switch modes would be nice. Or perhaps default to one mode when the debug module is loaded, and otherwise the other...