Skip to content

Commit

Permalink
test with PR
Browse files Browse the repository at this point in the history
  • Loading branch information
atteggiani committed Jul 10, 2023
1 parent bd0bed9 commit 07839ab
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions docs/js/miscellaneous.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,30 @@ function adjustScrollingToId() {
let header = document.querySelector('header');
let links = document.querySelectorAll("a[href^='#'].md-nav__link");

function adjustClick() {
let offset = header.offsetHeight;
links.forEach(link => link.addEventListener('click', e => {
const clickEvent = e => {
e.preventDefault();
window.scrollTo(0, document.querySelector(link.hash).offsetTop - offset);
}))
console.log('ciao');
}

let observer = new ResizeObserver(entries => adjustClick());
links.forEach(link => {
link.addEventListener('click', clickEvent)
})

// function adjustClick() {
// const clickEvent = (e) => {
// e.preventDefault();
// window.scrollTo(0, document.querySelector(e.target.hash).offsetTop - header.offsetHeight);
// }
// links.forEach(link => {
// link.removeEventListener('click', clickEvent);
// link.addEventListener('click', clickEvent);
// })
// }

// let observer = new ResizeObserver(entries => adjustClick());

adjustClick();
observer.observe(header);
// adjustClick();
// observer.observe(header);
}

// Join all functions
Expand Down

0 comments on commit 07839ab

Please sign in to comment.