wallet-core/node_modules/fbjs/lib/requestAnimationFrame.js

28 lines
797 B
JavaScript
Raw Normal View History

2017-05-03 15:35:00 +02:00
'use strict';
/**
2017-10-14 18:40:54 +02:00
* Copyright (c) 2014-present, Facebook, Inc.
2017-05-03 15:35:00 +02:00
*
2017-10-14 18:40:54 +02:00
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
2017-05-03 15:35:00 +02:00
*
*/
var emptyFunction = require('./emptyFunction');
var nativeRequestAnimationFrame = require('./nativeRequestAnimationFrame');
var lastTime = 0;
var requestAnimationFrame = nativeRequestAnimationFrame || function (callback) {
var currTime = Date.now();
var timeDelay = Math.max(0, 16 - (currTime - lastTime));
lastTime = currTime + timeDelay;
return global.setTimeout(function () {
callback(Date.now());
}, timeDelay);
};
// Works around a rare bug in Safari 6 where the first request is never invoked.
requestAnimationFrame(emptyFunction);
module.exports = requestAnimationFrame;