From 203de10249c9483ec931bc09ccc2180d2eb643d4 Mon Sep 17 00:00:00 2001 From: zsviczian Date: Sun, 26 Feb 2023 21:57:54 +0100 Subject: [PATCH] throttle take 3 --- src/components/App.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 37b57dc8a..2bee237cb 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -6448,10 +6448,16 @@ class App extends React.Component { isExporting: false, renderScrollbars: !this.device.isMobile, }; - renderingElements.forEach((el) => - setTimeout(() => generateElementWithCanvas(el, renderConfig)), - ); - setTimeout(() => this.setState({ shouldCacheIgnoreZoom: false })); + let i = 0; + for (; i < renderingElements.length; i += 200) { + const chunk = renderingElements.slice(i, i + 200); + setTimeout( + () => + chunk.forEach((el) => generateElementWithCanvas(el, renderConfig)), + i * 50, + ); + } + setTimeout(() => this.setState({ shouldCacheIgnoreZoom: false }), i * 50); } }, 300);