Skip to content

Commit 4681bb8

Browse files
committed
Moved request below callback. Ignore the argument and use performance.now instead for consistency with input events.
1 parent 50a167a commit 4681bb8

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/dom/RequestAnimationFrame.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,19 @@ var RequestAnimationFrame = new Class({
9292
* @type {FrameRequestCallback}
9393
* @since 3.0.0
9494
*/
95-
this.step = function step (timestamp)
95+
this.step = function step ()
9696
{
97+
// Because we cannot trust the time passed to this callback from the browser and need it kept in sync with event times
98+
var timestamp = window.performance.now();
99+
97100
// DOMHighResTimeStamp
98101
_this.lastTime = _this.tick;
99102

100103
_this.tick = timestamp;
101104

102-
_this.timeOutID = window.requestAnimationFrame(step);
103-
104105
_this.callback(timestamp);
106+
107+
_this.timeOutID = window.requestAnimationFrame(step);
105108
};
106109

107110
/**
@@ -122,9 +125,9 @@ var RequestAnimationFrame = new Class({
122125

123126
_this.tick = d;
124127

125-
_this.timeOutID = window.setTimeout(stepTimeout, delay);
126-
127128
_this.callback(d);
129+
130+
_this.timeOutID = window.setTimeout(stepTimeout, delay);
128131
};
129132
},
130133

0 commit comments

Comments
 (0)