mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: disable render throttling by default & during resize (#5451)
This commit is contained in:
parent
df14c69977
commit
5bc40402a6
11 changed files with 66 additions and 14 deletions
|
@ -166,7 +166,7 @@ import {
|
|||
isAndroid,
|
||||
} from "../keys";
|
||||
import { distance2d, getGridPoint, isPathALoop } from "../math";
|
||||
import { renderSceneThrottled } from "../renderer/renderScene";
|
||||
import { renderScene } from "../renderer/renderScene";
|
||||
import { invalidateShapeForElement } from "../renderer/renderElement";
|
||||
import {
|
||||
calculateScrollCenter,
|
||||
|
@ -286,6 +286,10 @@ let currentScrollBars: ScrollBars = { horizontal: null, vertical: null };
|
|||
let touchTimeout = 0;
|
||||
let invalidateContextMenu = false;
|
||||
|
||||
// remove this hack when we can sync render & resizeObserver (state update)
|
||||
// to rAF. See #5439
|
||||
let THROTTLE_NEXT_RENDER = true;
|
||||
|
||||
let lastPointerUp: ((event: any) => void) | null = null;
|
||||
const gesture: Gesture = {
|
||||
pointers: new Map(),
|
||||
|
@ -858,6 +862,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
|
||||
if ("ResizeObserver" in window && this.excalidrawContainerRef?.current) {
|
||||
this.resizeObserver = new ResizeObserver(() => {
|
||||
THROTTLE_NEXT_RENDER = false;
|
||||
// recompute device dimensions state
|
||||
// ---------------------------------------------------------------------
|
||||
this.refreshDeviceState(this.excalidrawContainerRef.current!);
|
||||
|
@ -1221,7 +1226,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||
);
|
||||
});
|
||||
|
||||
renderSceneThrottled(
|
||||
renderScene(
|
||||
renderingElements,
|
||||
this.state,
|
||||
this.state.selectionElement,
|
||||
|
@ -1259,8 +1264,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||
|
||||
this.scheduleImageRefresh();
|
||||
},
|
||||
THROTTLE_NEXT_RENDER && window.EXCALIDRAW_THROTTLE_RENDER === true,
|
||||
);
|
||||
|
||||
if (!THROTTLE_NEXT_RENDER) {
|
||||
THROTTLE_NEXT_RENDER = true;
|
||||
}
|
||||
|
||||
this.history.record(this.state, this.scene.getElementsIncludingDeleted());
|
||||
|
||||
// Do not notify consumers if we're still loading the scene. Among other
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue