scroll to content on collab scene init (#1201)
This commit is contained in:
parent
036978b837
commit
3afb4515b6
@ -35,6 +35,7 @@ import {
|
|||||||
getSelectedElements,
|
getSelectedElements,
|
||||||
globalSceneState,
|
globalSceneState,
|
||||||
isSomeElementSelected,
|
isSomeElementSelected,
|
||||||
|
calculateScrollCenter,
|
||||||
} from "../scene";
|
} from "../scene";
|
||||||
import {
|
import {
|
||||||
decryptAESGEM,
|
decryptAESGEM,
|
||||||
@ -743,9 +744,21 @@ export class App extends React.Component<any, AppState> {
|
|||||||
|
|
||||||
const updateScene = (
|
const updateScene = (
|
||||||
decryptedData: SocketUpdateDataSource["SCENE_INIT" | "SCENE_UPDATE"],
|
decryptedData: SocketUpdateDataSource["SCENE_INIT" | "SCENE_UPDATE"],
|
||||||
|
{ scrollToContent = false }: { scrollToContent?: boolean } = {},
|
||||||
) => {
|
) => {
|
||||||
const { elements: remoteElements } = decryptedData.payload;
|
const { elements: remoteElements } = decryptedData.payload;
|
||||||
|
|
||||||
|
if (scrollToContent) {
|
||||||
|
this.setState({
|
||||||
|
...this.state,
|
||||||
|
...calculateScrollCenter(
|
||||||
|
remoteElements.filter((element) => {
|
||||||
|
return !element.isDeleted;
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Perform reconciliation - in collaboration, if we encounter
|
// Perform reconciliation - in collaboration, if we encounter
|
||||||
// elements with more staler versions than ours, ignore them
|
// elements with more staler versions than ours, ignore them
|
||||||
// and keep ours.
|
// and keep ours.
|
||||||
@ -853,7 +866,7 @@ export class App extends React.Component<any, AppState> {
|
|||||||
return;
|
return;
|
||||||
case "SCENE_INIT": {
|
case "SCENE_INIT": {
|
||||||
if (!this.socketInitialized) {
|
if (!this.socketInitialized) {
|
||||||
updateScene(decryptedData);
|
updateScene(decryptedData, { scrollToContent: true });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user