From 4ab875bd20dfaf3ea7a0ce6e5e66b93135fb20c5 Mon Sep 17 00:00:00 2001 From: linbingquan <695601626@qq.com> Date: Mon, 23 Nov 2020 20:31:58 +0800 Subject: [PATCH] Clock: Clean up. --- src/core/Clock.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/Clock.js b/src/core/Clock.js index 8f2f45fac0..2dd5990d3c 100644 --- a/src/core/Clock.js +++ b/src/core/Clock.js @@ -14,7 +14,7 @@ class Clock { start() { - this.startTime = ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732 + this.startTime = now(); this.oldTime = this.startTime; this.elapsedTime = 0; @@ -50,7 +50,7 @@ class Clock { if ( this.running ) { - const newTime = ( typeof performance === 'undefined' ? Date : performance ).now(); + const newTime = now(); diff = ( newTime - this.oldTime ) / 1000; this.oldTime = newTime; @@ -65,4 +65,10 @@ class Clock { } +function now() { + + return ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732 + +} + export { Clock }; -- GitLab