Skip to content

Commit

Permalink
refactor(web): improve exit story block edit mode (#1347)
Browse files Browse the repository at this point in the history
Co-authored-by: airslice <[email protected]>
  • Loading branch information
mkumbobeaty and airslice authored Jan 23, 2025
1 parent 1141a0c commit a340b79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,5 @@ const PagesWrapper = styled("div")<{
}));

const PageGap = styled("div")<{ height?: number }>(({ height }) => ({
height: height ? `${height}px` : "70vh"
height: height ? `${height}px` : "70vh",
}));
13 changes: 11 additions & 2 deletions web/src/beta/features/Visualizer/Crust/StoryPanel/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,22 @@ export default (
setCurrentPageId(newPage.id);
setLayerOverride(undefined);

if (disableSelection) {
setDisableSelection(false);
setSelectedBlockId(undefined);
}

const container = document.getElementById(STORY_PANEL_CONTENT_ELEMENT_ID);
if (!pageId) {
if (container) container.scrollTo(0, 0); // If no pageId, newPage will be the first page and we scroll all the way to the top here
if (container) container.scrollTo(0, 0);
} else if (!disableScrollIntoView) {
const element = document.getElementById(`story-page-${newPage.id}`);
if (container && element) {
isAutoScrolling.current = true;
container.scrollTo({ top: element?.offsetTop, behavior: "smooth" });
container.scrollTo({
top: element.offsetTop,
behavior: "smooth"
});
}
}

Expand All @@ -163,6 +171,7 @@ export default (
currentPageId,
selectedStory?.pages,
onStoryPageChange,
disableSelection,
handlePageTime,
visualizer
]
Expand Down

0 comments on commit a340b79

Please sign in to comment.