mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Don't reset cache while zooming using a gesture (#1103)
* Don't reset cache while zooming using a gesture This reuses the cached canvas while the gesture is happening. Once it has stop updating, then recompute the cache with the proper zoom. This should massively improve performance when panning on big scenes on mobile Fixes #1056 * update snapshot tests
This commit is contained in:
parent
95eaadeb85
commit
24fa657093
8 changed files with 64 additions and 7 deletions
|
@ -481,6 +481,7 @@ export class App extends React.Component<any, AppState> {
|
|||
viewBackgroundColor: this.state.viewBackgroundColor,
|
||||
zoom: this.state.zoom,
|
||||
remotePointerViewportCoords: pointerViewportCoords,
|
||||
shouldCacheIgnoreZoom: this.state.shouldCacheIgnoreZoom,
|
||||
},
|
||||
{
|
||||
renderOptimizations: true,
|
||||
|
@ -1247,7 +1248,9 @@ export class App extends React.Component<any, AppState> {
|
|||
scrollX: normalizeScroll(this.state.scrollX + deltaX / this.state.zoom),
|
||||
scrollY: normalizeScroll(this.state.scrollY + deltaY / this.state.zoom),
|
||||
zoom: getNormalizedZoom(gesture.initialScale! * scaleFactor),
|
||||
shouldCacheIgnoreZoom: true,
|
||||
});
|
||||
this.resetShouldCacheIgnoreZoomDebounced();
|
||||
} else {
|
||||
gesture.lastCenter = gesture.initialDistance = gesture.initialScale = null;
|
||||
}
|
||||
|
@ -2553,6 +2556,10 @@ export class App extends React.Component<any, AppState> {
|
|||
this.socket && this.broadcastMouseLocation({ pointerCoords });
|
||||
};
|
||||
|
||||
private resetShouldCacheIgnoreZoomDebounced = debounce(() => {
|
||||
this.setState({ shouldCacheIgnoreZoom: false });
|
||||
}, 1000);
|
||||
|
||||
private saveDebounced = debounce(() => {
|
||||
saveToLocalStorage(globalSceneState.getAllElements(), this.state);
|
||||
}, 300);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue