Skip to content

Commit

Permalink
fix sidebar scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlauvlwj committed Oct 3, 2024
1 parent fd4735a commit 30d2eb7
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions themes/doc/lib/browser/navigation/components.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,19 @@ class Sidebar extends React.Component {
}

componentDidUpdate() {
if (this.props.visibleHeaderId) {
if ($(window).width() > 800) {
setTimeout(function () {
const $sidebar = $('.doc-sidebar');
const $firstItem = $($('.doc-sidebar-list').children('.doc-sidebar-list__item--link').get(0));
const $currentItem = $('.doc-sidebar-list__item--current');
if ($(window).width() > 800) {
setTimeout(function () {
const $sidebar = $('.doc-sidebar');
const $firstItem = $($('.doc-sidebar-list').children('.doc-sidebar-list__item--link').get(0));
const $currentItem = $('.doc-sidebar-list__item--current');

if ($currentItem.length > 0) {
const offset = $currentItem.position().top - $firstItem.position().top;
if (offset > 100) {
$sidebar.animate({ scrollTop: offset }, 800);
}
if ($currentItem.length > 0) {
const offset = $currentItem.position().top - $firstItem.position().top;
if (offset > 100) {
$sidebar.animate({ scrollTop: offset }, 800);
}
}, 100);
}
}
}, 100);
}
}

Expand Down

0 comments on commit 30d2eb7

Please sign in to comment.