mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
scroll the closest element to center (#1670)
Co-authored-by: Sanghyeon Lee <yongdamsh@gmail.com>
This commit is contained in:
parent
0db7ac78c4
commit
fa359034c5
10 changed files with 100 additions and 15 deletions
|
@ -271,7 +271,7 @@ export const importFromBackend = async (
|
|||
}
|
||||
|
||||
elements = data.elements || elements;
|
||||
appState = data.appState || appState;
|
||||
appState = { ...appState, ...data.appState };
|
||||
} catch (error) {
|
||||
window.alert(t("alerts.importBackendFailed"));
|
||||
console.error(error);
|
||||
|
|
|
@ -84,6 +84,5 @@ export const restoreFromLocalStorage = () => {
|
|||
// Do nothing because appState is already null
|
||||
}
|
||||
}
|
||||
|
||||
return restore(elements, appState);
|
||||
};
|
||||
|
|
|
@ -121,7 +121,10 @@ export const restore = (
|
|||
}, [] as ExcalidrawElement[]);
|
||||
|
||||
if (opts?.scrollToContent && savedState) {
|
||||
savedState = { ...savedState, ...calculateScrollCenter(elements) };
|
||||
savedState = {
|
||||
...savedState,
|
||||
...calculateScrollCenter(elements, savedState, null),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue