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:
parent
97aef1faea
commit
885c39b9c3
1 changed files with 12 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue