mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
feat: rerender canvas on focus (#8035)
This commit is contained in:
parent
afe52c89a7
commit
1b6e3fe05b
1 changed files with 12 additions and 2 deletions
|
@ -2594,6 +2594,9 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
),
|
),
|
||||||
addEventListener(window, EVENT.FOCUS, () => {
|
addEventListener(window, EVENT.FOCUS, () => {
|
||||||
this.maybeCleanupAfterMissingPointerUp(null);
|
this.maybeCleanupAfterMissingPointerUp(null);
|
||||||
|
// browsers (chrome?) tend to free up memory a lot, which results
|
||||||
|
// in canvas context being cleared. Thus re-render on focus.
|
||||||
|
this.triggerRender(true);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3729,8 +3732,15 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
private triggerRender = () => {
|
private triggerRender = (
|
||||||
this.setState({});
|
/** force always re-renders canvas even if no change */
|
||||||
|
force?: boolean,
|
||||||
|
) => {
|
||||||
|
if (force === true) {
|
||||||
|
this.scene.triggerUpdate();
|
||||||
|
} else {
|
||||||
|
this.setState({});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue