Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TarasKachmar2022 committed Mar 8, 2024
1 parent de983a5 commit c5be9a0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/js/smooth-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ document.querySelectorAll('a.site-nav__link').forEach(link => {

const scrollTarget = document.getElementById(href);

let topOffset = 0;
topOffset = topOffsetSelector();
let headerTopOffset = 0;
headerTopOffset = topOffsetSelector();

const elementPosition = scrollTarget.getBoundingClientRect().top;
const offsetPosition = elementPosition - topOffset;
const offsetPosition = elementPosition - headerTopOffset;

window.scrollBy({ top: offsetPosition, behavior: 'smooth' });
});
Expand All @@ -19,11 +19,11 @@ document.querySelectorAll('a.site-nav__link').forEach(link => {
const viewportWidth = window.innerWidth;

if (viewportWidth >= 768) {
topOffset = 82;
return topOffset;
headerTopOffset = 82;
return headerTopOffset;
} else {
topOffset = 104;
return topOffset;
headerTopOffset = 104;
return headerTopOffset;
}
}
});

0 comments on commit c5be9a0

Please sign in to comment.