, op = require('Y/op')
, Emitter = require('Y/modules/y.event').Emitter
-, MIN_TICK_INTERVAL = 0 // ms
, NUM_SAMPLES = 33
,
timer : null,
running : false,
+ dropped : 0, // Frames dropped since last tick
times : null, // Last `samples` frame durations
if (this.running) return;
this.running = true;
+ this.dropped = 0;
this.now = new Date().getTime() - (this.elapsedAtStop || this.targetTime);
this.emit('start');
sleepMinus : function sleepMinus(tFrame){
if (this.timer !== null) return;
- var tickInt = Math.max(MIN_TICK_INTERVAL, this.targetTime - tFrame);
+ var tt = this.targetTime
+ , tickInt = tt - tFrame;
+ if ( tickInt <= 0 ) {
+ this.dropped = Math.floor(tFrame / tt);
+ tickInt = tt - (tFrame % tt);
+ }
+
this.timer = setTimeout(this.tick, tickInt);
},
this.emit('tick', this, {
'now' : this.clock,
'elapsed' : this.perceived,
- 'ticks' : ++this.ticks
+ 'ticks' : ++this.ticks,
+ 'dropped' : this.dropped
});
var tFrame = this.tFrame = new Date().getTime() - this.now;