Skip to content

Commit

Permalink
fix: achor smooth scroll into view
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jun 7, 2020
1 parent 05bed2d commit 7aa9497
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ui/blocks/src/PageContainer/PageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,22 @@ export const PageContainer: FC<PageContainerProps & BoxProps> = forwardRef(
if (scrollId) {
const element = document.getElementById(scrollId);
if (element) {
setTimeout(() => {
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
}, 100);

/*
const offsetTop =
element.getBoundingClientRect().top + window.pageYOffset - 60;
element.getBoundingClientRect().top + window.pageYOffset - 30;
// Introducing a delay to ensure scrolling works when it's a full refresh.
setTimeout(() => {
window.scroll({
top: offsetTop,
behavior: 'smooth',
});
}, 100);
*/
}
}
} catch (err) {}
Expand Down
1 change: 1 addition & 0 deletions ui/components/src/BlockContainer/BlockContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const BlockContainer: FC<BlockContainerProps> = ({
mt: 4,
mb: 4,
width: '100%',
scrollMarginTop: '5rem',
...sxStyle,
}}
id={blockId}
Expand Down

0 comments on commit 7aa9497

Please sign in to comment.