mirror of
https://github.com/photonstorm/phaser
synced 2024-12-23 03:23:42 +00:00
31 lines
605 B
JavaScript
31 lines
605 B
JavaScript
/**
|
|
* performance.now
|
|
*/
|
|
(function () {
|
|
|
|
if ('performance' in window === false)
|
|
{
|
|
window.performance = {};
|
|
}
|
|
|
|
// Thanks IE8
|
|
Date.now = (Date.now || function () {
|
|
return new Date().getTime();
|
|
});
|
|
|
|
if ('now' in window.performance === false)
|
|
{
|
|
var nowOffset = Date.now();
|
|
|
|
if (performance.timing && performance.timing.navigationStart)
|
|
{
|
|
nowOffset = performance.timing.navigationStart;
|
|
}
|
|
|
|
window.performance.now = function now ()
|
|
{
|
|
return Date.now() - nowOffset;
|
|
}
|
|
}
|
|
|
|
})();
|