Skip to content

Commit

Permalink
Merge pull request #644 from bjhijmans/master
Browse files Browse the repository at this point in the history
Menu items now open when you scroll down in the default theme.
  • Loading branch information
shalvah authored Apr 12, 2023
2 parents 53faab8 + d2c119e commit fbe609c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions resources/js/theme-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,18 @@ document.addEventListener('DOMContentLoaded', function() {

window.addEventListener('hashchange', hashChange, false);

const divs = document.querySelectorAll('.content h1[id], .content h2[id]');

document.addEventListener('scroll', () => {
divs.forEach(item => {
const rect = item.getBoundingClientRect();
if (rect.top > 0 && rect.top < 150) {
const location = window.location.toString().split('#')[0];
history.replaceState(null, null, location + '#' + item.id);
hashChange();
}
});
});

hashChange();
});

0 comments on commit fbe609c

Please sign in to comment.