Skip to content

Commit

Permalink
ui: Smooth scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjaiyan-dev authored Oct 31, 2023
1 parent 1089741 commit 9b4da4b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/docusaurus/src/client/ClientLifecyclesDispatcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ function scrollAfterNavigation({

const {hash} = location;
if (!hash) {
window.scrollTo(0, 0);
window.scrollTo({
top: 0,
left: 0,
behavior: 'smooth',
});
} else {
const id = decodeURIComponent(hash.substring(1));
const element = document.getElementById(id);
element?.scrollIntoView();
element?.scrollIntoView({behavior: 'smooth'});
}
}

Expand Down

0 comments on commit 9b4da4b

Please sign in to comment.