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:
Aakansha Doshi 2021-02-21 19:01:34 +05:30 committed by GitHub
parent d17464fbaa
commit 7c5481b877
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 18 deletions

View file

@ -18,6 +18,8 @@ Please add the latest change on the top under the correct section.
### Features
- Add support for `scrollToCenter` in [initialData](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L18) so host can control whether to scroll to center on mount [#3070](https://github.com/excalidraw/excalidraw/pull/3070).
- Export [`restore`](https://github.com/excalidraw/excalidraw/blob/master/src/data/restore.ts#L182), [`restoreAppState`](https://github.com/excalidraw/excalidraw/blob/master/src/data/restore.ts#L144) and [`restoreElements`](https://github.com/excalidraw/excalidraw/blob/master/src/data/restore.ts#L128) to host
### Fixes

View file

@ -286,10 +286,11 @@ Here you can try saving the data to your backend or local storage for example.
This helps to load Excalidraw with `initialData`. It must be an object or a [promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise) which resolves to an object containing the below optional fields.
| name | type |
| --- | --- |
| elements | [ExcalidrawElement[]](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78) |
| appState | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L37) |
| Name | Type | Descrption |
| --- | --- | --- |
| `elements` | [ExcalidrawElement[]](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78) | The elements with which Excalidraw should be mounted. |
| `appState` | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L37) | The App state with which Excalidraw should be mounted. |
| `scrollToCenter` | boolean | This attribute implies whether to scroll to the center once Excalidraw is mounted. By default, it will not scroll to the center. |
```json
{