craftyjs/Crafty — pull request #313 by austinh (2012-07-15 22:47:46+00:00)
Title: Fix rAF with Firefox on pause within event frame and fix preventDefault ...

...and stopPropagation with MSIE.

I re based and cleaned up my edits. Now the entire commit does not rewrite the entire file.

While pausing a game from inside an EnterFrame event, Firefox returns the following error:

NS_ERROR_XPC_BAD_CONVERT_JS: Component returned failure code: 0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS) [nsIDOMWindow.mozRequestAnimationFrame]

The following psuedo code gives this error.
Crafty.bind("EnterFrame", function()
{
if(GameOver == true)
{
Crafty.pause();
}
});

This is fixed by adding a 0ms setTimeout to the timer.stop() and timer.init() functions, which essentially means the pause/stop will not be run until after the JS Compiler has finished running the last EnterFrame function call.

When using the Keyboard dispatch I get the following errors in IE7 and 8:

Object doesn't support property or method 'preventDefault' in IE8.
Object doesn't support property or method 'stopPropogation'

I created a simple solution in this pull request.