Skip to content

Commit

Permalink
Adding a heartbeat to prevent Safari from sleeping. Fixes #140
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Nov 1, 2014
1 parent 1918258 commit 9ef541a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions js/Sim.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ define( function( require ) {
$body.append( $simDiv );
this.$simDiv = $simDiv;

// for preventing Safari from going to sleep. see https://github.com/phetsims/joist/issues/140
var heartbeatDiv = this.heartbeatDiv = document.createElement( 'div' );
heartbeatDiv.style.opacity = 0;
document.body.appendChild( heartbeatDiv );

//Create the scene
//Leave accessibility as a flag while in development
sim.scene = new Scene( $simDiv, {
Expand Down Expand Up @@ -580,6 +585,11 @@ define( function( require ) {

phetAllocation && phetAllocation( 'loop' );

// prevent Safari from going to sleep, see https://github.com/phetsims/joist/issues/140
if ( sim.frameCounter % 1000 === 0 ) {
sim.heartbeatDiv.innerHTML = Math.random();
}

// fire or synthesize input events
if ( sim.options.fuzzMouse ) {
sim.fuzzMouseEvents();
Expand Down

0 comments on commit 9ef541a

Please sign in to comment.