mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
added Date.now fallback to Common.now, closes #739
This commit is contained in:
parent
991500793c
commit
c06c10735f
1 changed files with 6 additions and 2 deletions
|
@ -252,9 +252,9 @@ module.exports = Common;
|
|||
|
||||
/**
|
||||
* Returns the current timestamp since the time origin (e.g. from page load).
|
||||
* The result will be high-resolution including decimal places if available.
|
||||
* The result is in milliseconds and will use high-resolution timing if available.
|
||||
* @method now
|
||||
* @return {number} the current timestamp
|
||||
* @return {number} the current timestamp in milliseconds
|
||||
*/
|
||||
Common.now = function() {
|
||||
if (typeof window !== 'undefined' && window.performance) {
|
||||
|
@ -265,6 +265,10 @@ module.exports = Common;
|
|||
}
|
||||
}
|
||||
|
||||
if (Date.now) {
|
||||
return Date.now();
|
||||
}
|
||||
|
||||
return (new Date()) - Common._nowStartTime;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue