Skip to content

Commit

Permalink
feat: scroll the selected element to the center of the viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
ARandomOWL committed Feb 15, 2024
1 parent 134003b commit 06082a4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const scrollToElement = (searchEngine, element) => {
// scroll element to bottom
element.scrollIntoView(false);
window.scrollBy(0, bottomMargin);
} else {
window.scrollTo(0, elementBounds.top + window.pageYOffset - (window.innerHeight / 2));
}
return Math.abs(window.scrollY - scrollY) > 0.01;
};
Expand Down

0 comments on commit 06082a4

Please sign in to comment.