0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

added high resolution timing

This commit is contained in:
liabru 2014-03-14 19:37:45 +00:00
parent 97aef1faea
commit 885c39b9c3

View file

@ -195,13 +195,23 @@ var Common = {};
/**
* Description
* @method now
* @return {Date} the current DateTime
* @return {number} the current timestamp (high-res if avaliable)
*/
Common.now = Date.now || function() {
Common.now = function() {
// http://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript
// https://gist.github.com/davidwaterston/2982531
var perf = window.performance;
if (perf) {
perf.now = perf.now || perf.webkitNow || perf.msNow || perf.oNow || perf.mozNow;
return +(perf.now());
}
return +(new Date());
};
/**
* Description
* @method random