Skip to content

Commit

Permalink
fix: adjust anchor smooth scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jun 2, 2020
1 parent c0c750c commit 72bbc3d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ui/blocks/src/PageContainer/PageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ export const PageContainer: FC<PageContainerProps> = forwardRef(
if (scrollId) {
const element = document.getElementById(scrollId);
if (element) {
const offsetTop =
element.getBoundingClientRect().top + window.pageYOffset - 60;
// Introducing a delay to ensure scrolling works when it's a full refresh.
setTimeout(() => {
element.scrollIntoView({
window.scroll({
top: offsetTop,
behavior: 'smooth',
block: 'end',
inline: 'nearest',
});
}, 100);
}
Expand Down

0 comments on commit 72bbc3d

Please sign in to comment.