$(function() {
/* Fixed Header */
let header = $("#header");
let intro = $("#intro");
let introH;
let scrollPos = $(window).scrollTop();
$(window).on("scroll load resize", function() {
introH = intro.innerHeight();
scrollPos = $(this).scrollTop();
if( scrollPos > introH ) {
header.addClass("fixed");
} else {
header.removeClass("fixed");
}
});
/* Smooth scroll */
$("[data-scroll]").on("click", function(event) {
event.preventDefault();
let elementId = $(this).data('scroll');
let elementOffset = $(elementId).offset().top;
console.log(elementOffset);
});
});
app.js:25 Uncaught TypeError: Cannot read property 'top' of undefined
at HTMLAnchorElement.<anonymous> (app.js:25)
at HTMLAnchorElement.dispatch (jquery.min.js:2)
at HTMLAnchorElement.v.handle (jquery.min.js:2)
(anonymous) @ app.js:25
dispatch @ jquery.min.js:2
v.handle @ jquery.min.js:2