Skip to content

Commit

Permalink
Use boolean flip for heartbeat instead of random, see phetsims/states…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisklus committed Aug 21, 2020
1 parent 1ffb7b6 commit 1bf6490
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion js/Heartbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import joist from './joist.js';
// variables
let started = false;

// a boolean to flip back and forth to make sure safari doesn't get sleepy, see usage.
let value = true;

const Heartbeat = {

/**
Expand Down Expand Up @@ -41,7 +44,8 @@ const Heartbeat = {
// prevent Safari from going to sleep, see https://github.com/phetsims/joist/issues/140
sim.frameStartedEmitter.addListener( function() {
if ( sim.frameCounter % 1000 === 0 ) {
heartbeatDiv.innerHTML = phet.joist.random.nextDouble();
value = !value;
heartbeatDiv.innerHTML = value;
}
} );
}
Expand Down

0 comments on commit 1bf6490

Please sign in to comment.