parent
79e4c4a104
commit
2ca8fa6e66
5 changed files with 16 additions and 7 deletions
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
module.exports = function(callback) {
|
||||
//60fps translates to 16.6ms, round it down since setTimeout requires int
|
||||
var time = 16
|
||||
var time = 16
|
||||
var last = 0, pending = null
|
||||
var timeout = typeof requestAnimationFrame === "function" ? requestAnimationFrame : setTimeout
|
||||
return function(synchronous) {
|
||||
var now = new Date().getTime()
|
||||
var diff = now - last
|
||||
if (synchronous === true || last === 0 || now - last >= time) {
|
||||
last = now
|
||||
callback()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue