darkf/heart.js — pull request #9 by 00Davo (2014-01-01 04:23:09+00:00)
Title: heart.focus() callback function to correspond to love.focus()

Adds support for calling a `heart.focus()` callback using the same API as `love.focus()`; also includes an example, `examples/pausable.html` , to demonstrate that this works.

Currently `window.onfocus` and `window.onblur` are used to track focus. This corresponds fairly well to the way `love.focus()` works, i.e., focus is tied to whether the game window is active. However, it does mean you can't "click out" of a game onto another part of the same Web page to de-focus the game. I initially tried using the `focus` and `blur` events of the *canvas*, but it turns out `` elements cannot be focused by default in browsers so those events never fire.