Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Tweaks to polling heartbeat: use setTimeout rather than setInterval t…
Browse files Browse the repository at this point in the history
…o prevent backing up. Allow setting html{-pie-poll-interval:N} to customize the interval on a page.
  • Loading branch information
lojjic committed May 28, 2012
1 parent 9e1b42b commit 4b12b74
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sources/Heartbeat.js
Expand Up @@ -2,15 +2,20 @@
* Simple heartbeat timer - this is a brute-force workaround for syncing issues caused by IE not
* always firing the onmove and onresize events when elements are moved or resized. We check a few
* times every second to make sure the elements have the correct position and size. See Element.js
* which adds heartbeat listeners based on the custom -pie-poll flag, which defaults to true in IE8
* which adds heartbeat listeners based on the custom -pie-poll flag, which defaults to true in IE8-9
* and false elsewhere.
*/

PIE.Heartbeat = new PIE.Observable();
PIE.Heartbeat.run = function() {
var me = this;
var me = this,
interval;
if( !me.running ) {
setInterval( function() { me.fire() }, 250 );
interval = doc.documentElement.currentStyle.getAttribute( PIE.CSS_PREFIX + 'poll-interval' ) || 250;
(function beat() {
me.fire();
setTimeout(beat, interval);
})();
me.running = 1;
}
};

0 comments on commit 4b12b74

Please sign in to comment.