Skip to content

Commit

Permalink
Merge pull request #27261 from Talha345/fix/23810
Browse files Browse the repository at this point in the history
Fix LHN toggle in responsive view!
  • Loading branch information
tgolen committed Sep 15, 2023
2 parents 83b3f5d + dced655 commit 191bda1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions docs/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,6 @@ window.addEventListener('DOMContentLoaded', () => {

// If there is a fixed article scroll container, set to calculate titles' offset
scrollContainer: 'content-area',

// onclick function to apply to all links in toc. will be called with
// the event as the first parameter, and this can be used to stop,
// propagation, prevent default or perform action
onClick() {
toggleHeaderMenu();
},
});
}

Expand All @@ -226,6 +219,18 @@ window.addEventListener('DOMContentLoaded', () => {

const articleContent = document.getElementById('article-content');
const lhnContent = document.getElementById('lhn-content');

// This event listener checks if a link clicked in the LHN points to some section of the same page and toggles
// the LHN menu in responsive view.
lhnContent.addEventListener('click', (event) => {
const clickedLink = event.target;
if (clickedLink) {
const href = clickedLink.getAttribute('href');
if (href && href.startsWith('#') && !!document.getElementById(href.slice(1))) {
toggleHeaderMenu();
}
}
});
lhnContent.addEventListener('wheel', (e) => {
const scrollTop = lhnContent.scrollTop;
const isScrollingPastLHNTop = e.deltaY < 0 && scrollTop === 0;
Expand Down

0 comments on commit 191bda1

Please sign in to comment.