delay scene init until document active (#1920)

* delay scene init until document active

* use opts.once for the listener
This commit is contained in:
David Luzar 2020-07-20 12:53:53 +02:00 committed by GitHub
parent cf36cb394b
commit b07aa6e205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -474,6 +474,14 @@ class App extends React.Component<ExcalidrawProps, AppState> {
window.history.replaceState({}, "Excalidraw", window.location.origin); window.history.replaceState({}, "Excalidraw", window.location.origin);
} }
} else { } else {
// https://github.com/excalidraw/excalidraw/issues/1919
if (document.hidden) {
window.addEventListener("focus", () => this.initializeScene(), {
once: true,
});
return;
}
isCollaborationScene = false; isCollaborationScene = false;
window.history.replaceState({}, "Excalidraw", window.location.origin); window.history.replaceState({}, "Excalidraw", window.location.origin);
} }