Skip to content

Commit

Permalink
perf: 优化查找性能,平衡每次查找的数量与间隔
Browse files Browse the repository at this point in the history
  • Loading branch information
yujinpan committed Feb 1, 2021
1 parent 2e09e88 commit 5861455
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/super-image-reptile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit 5861455

Please sign in to comment.