all files / lib/src/polyfills/ requestAnimationFrame.js

100% Statements 10/10
50% Branches 3/6
100% Functions 3/3
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21   131075× 131075× 18× 18×   131057×                    
export var polyfill = (function () {
	var clock = Date.now()
 
	return function (callback) {
		var currentTime = Date.now()
		if (currentTime - clock > 16) {
			clock = currentTime
			callback(currentTime)
		} else {
			setTimeout(function () { return polyfill(callback); }, 0)
		}
	}
})()
 
 
export var requestAnimationFrame = window.requestAnimationFrame
	|| window.webkitRequestAnimationFrame
	|| window.mozRequestAnimationFrame
	|| polyfill