Skip to content

Commit 30d2eb7

Browse files
fix sidebar scrolling
1 parent fd4735a commit 30d2eb7

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

themes/doc/lib/browser/navigation/components.jsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,19 @@ class Sidebar extends React.Component {
2828
}
2929

3030
componentDidUpdate() {
31-
if (this.props.visibleHeaderId) {
32-
if ($(window).width() > 800) {
33-
setTimeout(function () {
34-
const $sidebar = $('.doc-sidebar');
35-
const $firstItem = $($('.doc-sidebar-list').children('.doc-sidebar-list__item--link').get(0));
36-
const $currentItem = $('.doc-sidebar-list__item--current');
31+
if ($(window).width() > 800) {
32+
setTimeout(function () {
33+
const $sidebar = $('.doc-sidebar');
34+
const $firstItem = $($('.doc-sidebar-list').children('.doc-sidebar-list__item--link').get(0));
35+
const $currentItem = $('.doc-sidebar-list__item--current');
3736

38-
if ($currentItem.length > 0) {
39-
const offset = $currentItem.position().top - $firstItem.position().top;
40-
if (offset > 100) {
41-
$sidebar.animate({ scrollTop: offset }, 800);
42-
}
37+
if ($currentItem.length > 0) {
38+
const offset = $currentItem.position().top - $firstItem.position().top;
39+
if (offset > 100) {
40+
$sidebar.animate({ scrollTop: offset }, 800);
4341
}
44-
}, 100);
45-
}
42+
}
43+
}, 100);
4644
}
4745
}
4846

0 commit comments

Comments
 (0)