throttle attempt
This commit is contained in:
parent
1d5e865da1
commit
48deb68326
@ -1283,7 +1283,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderScene = () => {
|
private renderScene = (
|
||||||
|
renderingElements: NonDeletedExcalidrawElement[] = [],
|
||||||
|
shouldCacheIgnoreZoom: boolean | null = null,
|
||||||
|
) => {
|
||||||
const cursorButton: {
|
const cursorButton: {
|
||||||
[id: string]: string | undefined;
|
[id: string]: string | undefined;
|
||||||
} = {};
|
} = {};
|
||||||
@ -1321,9 +1324,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
cursorButton[socketId] = user.button;
|
cursorButton[socketId] = user.button;
|
||||||
});
|
});
|
||||||
|
|
||||||
const renderingElements = this.scene
|
renderingElements =
|
||||||
.getNonDeletedElements()
|
renderingElements.length > 0
|
||||||
.filter((element) => {
|
? renderingElements
|
||||||
|
: this.scene.getNonDeletedElements().filter((element) => {
|
||||||
if (isImageElement(element)) {
|
if (isImageElement(element)) {
|
||||||
if (
|
if (
|
||||||
// not placed on canvas yet (but in elements array)
|
// not placed on canvas yet (but in elements array)
|
||||||
@ -1363,7 +1367,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
remoteSelectedElementIds,
|
remoteSelectedElementIds,
|
||||||
remotePointerUsernames: pointerUsernames,
|
remotePointerUsernames: pointerUsernames,
|
||||||
remotePointerUserStates: pointerUserStates,
|
remotePointerUserStates: pointerUserStates,
|
||||||
shouldCacheIgnoreZoom: this.state.shouldCacheIgnoreZoom,
|
shouldCacheIgnoreZoom:
|
||||||
|
shouldCacheIgnoreZoom === null
|
||||||
|
? this.state.shouldCacheIgnoreZoom
|
||||||
|
: shouldCacheIgnoreZoom,
|
||||||
theme: this.state.theme,
|
theme: this.state.theme,
|
||||||
imageCache: this.imageCache,
|
imageCache: this.imageCache,
|
||||||
isExporting: false,
|
isExporting: false,
|
||||||
@ -6367,7 +6374,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
|
|
||||||
private resetShouldCacheIgnoreZoomDebounced = debounce(() => {
|
private resetShouldCacheIgnoreZoomDebounced = debounce(() => {
|
||||||
if (!this.unmounted) {
|
if (!this.unmounted) {
|
||||||
this.setState({ shouldCacheIgnoreZoom: false });
|
//generateElementWithCanvas
|
||||||
|
const elements = this.scene.getNonDeletedElements();
|
||||||
|
for (let i = 0; i < elements.length; i += 200) {
|
||||||
|
const chunk = elements.slice(i, i + 200);
|
||||||
|
setTimeout(() => this.renderScene(chunk, false));
|
||||||
|
}
|
||||||
|
setTimeout(() => this.setState({ shouldCacheIgnoreZoom: false }));
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user