Skip to content

Commit

Permalink
未启动时渲染辅助元素降频处理
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinlic committed Nov 28, 2023
1 parent fded42e commit 58e03c7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/CaptureContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
}

/**
Expand Down Expand Up @@ -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];
Expand All @@ -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)
Expand Down

0 comments on commit 58e03c7

Please sign in to comment.