From 58e03c7574b788f88371736ed9dd62b194f1dddc Mon Sep 17 00:00:00 2001 From: Vinlic Date: Tue, 28 Nov 2023 13:59:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E5=90=AF=E5=8A=A8=E6=97=B6=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E8=BE=85=E5=8A=A9=E5=85=83=E7=B4=A0=E9=99=8D=E9=A2=91?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/CaptureContext.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/CaptureContext.js b/core/CaptureContext.js index 90475b9..d536ea8 100644 --- a/core/CaptureContext.js +++ b/core/CaptureContext.js @@ -240,8 +240,12 @@ export default class CaptureContext { (function update() { rotate = rotate >= 360 ? 0 : (rotate + 0.1); captureHelper.style.transform = `rotate(${rotate}deg)`; - ____setTimeout(update, 0); - })(); + // 如果已启动则高频更新,未启动时摸鱼 + if (this.startFlag) + ____setTimeout(update.bind(this), 0); + else + ____setTimeout(update.bind(this), 1000); + }).bind(this)(); } /** @@ -476,7 +480,7 @@ export default class CaptureContext { * @private */ _callIntervalCallbacks(currentTime) { - if(this.intervalCallbacks.length == 0) + if (this.intervalCallbacks.length == 0) return; for (let i = 0; i < this.intervalCallbacks.length; i++) { const [timerId, timestamp, interval, fn] = this.intervalCallbacks[i]; @@ -494,7 +498,7 @@ export default class CaptureContext { * @private */ _callTimeoutCallbacks(currentTime) { - if(this.timeoutCallbacks.length == 0) + if (this.timeoutCallbacks.length == 0) return; this.timeoutCallbacks = this.timeoutCallbacks.filter(([timerId, timestamp, timeout, fn]) => { if (currentTime < timestamp + timeout)