mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-23 09:26:51 -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,12 +195,22 @@ 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
|
||||
|
|
Loading…
Reference in a new issue