feat: Add support for scrollToCenter in initialData so host can control whether to scroll to center on mount (#3070)
* feat: Add support for scrollToCenter in initialData so host can control whether to scroll to center on mount * fix * update changelog and readme * fix * Scroll to center only for collab and shareable links in excalidraw app * fix test * update readme * Update src/packages/excalidraw/README.md
This commit is contained in:
@ -672,19 +672,24 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
||||
|
||||
scene.appState = {
|
||||
...scene.appState,
|
||||
...calculateScrollCenter(
|
||||
scene.elements,
|
||||
{
|
||||
...scene.appState,
|
||||
width: this.state.width,
|
||||
height: this.state.height,
|
||||
offsetTop: this.state.offsetTop,
|
||||
offsetLeft: this.state.offsetLeft,
|
||||
},
|
||||
null,
|
||||
),
|
||||
isLoading: false,
|
||||
};
|
||||
if (initialData?.scrollToCenter) {
|
||||
scene.appState = {
|
||||
...scene.appState,
|
||||
...calculateScrollCenter(
|
||||
scene.elements,
|
||||
{
|
||||
...scene.appState,
|
||||
width: this.state.width,
|
||||
height: this.state.height,
|
||||
offsetTop: this.state.offsetTop,
|
||||
offsetLeft: this.state.offsetLeft,
|
||||
},
|
||||
null,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
this.resetHistory();
|
||||
this.syncActionResult({
|
||||
|
Reference in New Issue
Block a user