Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

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.

/* 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...

10 years ago by stahlmanDesign

I was talking with someone the other day about whether or not you could fork Impact, make your proposed improvements / changes and submit them to Dominic for consideration in a future version. For something fundamental like this, as opposed to features, I don't see why not.
Page 1 of 1
« first « previous next › last »