javascript - Safari and requestAnimationFrame gets DOMHighResTimestamp; window.performance not available -


i created animation using requestanimationframe. works fine in windows chrome , ie; safari (tested safari 6 , 7) breaks. turns out raf domhighrestimestamp rather date timestamp. that's fine , good, , expected, it's part of spec. however, far i've been able find, there's no way current domhighrestimestamp (i.e. window.performance not available, prefix). if create start time date timestamp, behaves radically wrong when try determine progress within raf callback (very small negative numbers).

if @ this jsbin on safari, won't animate @ all.

in this jbin, i've made change "skip" first frame (where time parameter undefined), starttime gets set time parameter on next frame. seems work, skipping frame seems bit crappy.

is there way current domhighrestimestamp in safari, given lack of window.performance? or alternately, force raf sort of legacy mode forces date timestamp instead?

does know why safari has inconsistency, provides parameter in format can't @ other way?

performance.now() recommendation of now. https://developer.mozilla.org/en-us/docs/web/api/performance.now() can assume it's matter of time before it's official, seeing how safari has built in.

besides fact use advantage. since know requestanimationframe returns domhighrestimestamp use timing.

game.start = function(timestamp){     if(timestamp){         this.time = timestamp;         requestanimationframe(game.loop);     }else{         requestanimationframe(game.start);     } }  game.loop = function(timestamp){     game.tick(timestamp);     ... code     requestanimationframe(game.loop); }  game.tick = function(timestamp) {     this.delta      = timestamp - this.time;     this.time       = timestamp; }; 

what here, call game.start begin loop (i've run situations timestamp undefined try until valid). once have our base time , since raf going return timestamp our tick function never has call date.now or performance.now long pass timestamp returned requestanimationframe.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -