From 58614554bea4c047f7e1aa7b83d8e0d51026204b Mon Sep 17 00:00:00 2001 From: yujinpan <1192878390@qq.com> Date: Mon, 1 Feb 2021 18:17:42 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E6=80=A7=E8=83=BD=EF=BC=8C=E5=B9=B3=E8=A1=A1=E6=AF=8F=E6=AC=A1?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=E7=9A=84=E6=95=B0=E9=87=8F=E4=B8=8E=E9=97=B4?= =?UTF-8?q?=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/super-image-reptile.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/super-image-reptile.js b/scripts/super-image-reptile.js index cfe8b6a..b5370ef 100644 --- a/scripts/super-image-reptile.js +++ b/scripts/super-image-reptile.js @@ -218,7 +218,12 @@ if (++index < len) { // 延迟计算(解决卡顿问题) - timeId = setTimeout(() => each(), 0); + // 每进行 50 次计算就休息一次 + if (Number.isInteger(index / 50)) { + timeId = setTimeout(() => each(), 0); + } else { + each(); + } } else { elem.classList.remove('active'); }