showing results for - "smooth scroll to target with offset"
Pedro
31 Jun 2018
1function scrollToTargetAdjusted(){
2    var element = document.getElementById('targetElement');
3    var headerOffset = 45;
4    var elementPosition = element.getBoundingClientRect().top;
5    var offsetPosition = elementPosition - headerOffset;
6
7    window.scrollTo({
8         top: offsetPosition,
9         behavior: "smooth"
10    });
11}
12