我正在使用由开发人员创建的 Easy Dots Scroll 库,该库是我从 github 在网站项目上下载的,三个滚动点出现在侧面,但是当我单击其中任何一个以跳转到网站上的部分时由点表示它不起作用,在控制台中我收到错误
script2.js:184 Uncaught TypeError: Cannot read property 'top' of undefined
检查控制台中的代码这是包含错误的代码部分
`
function scrollIndiClicked(indiId) {
if (window.jQuery) {
// if jquery is availble then we can use jquery animations
if (dotFixedNavPresent === true && dotFixedNavId.length) {
// there is a fixed nav and its id has been defined
const dotNavHeightElem = document.getElementById(dotFixedNavId);
const dotNavHeight = dotNavHeightElem.clientHeight;
const dotDocumentHtml = $('html, body');
const indiElement = $('#' + indiId);
if (dotFixedNavUp === true) {
// fix nav on upward scroll only
dotDocumentHtml.animate({
scrollTop: indiElement.offset().top
}, 700);
const scrollPos = document.body.getBoundingClientRect().top;
setTimeout(function () {
if (document.body.getBoundingClientRect().top > scrollPos) {
dotDocumentHtml.animate({
scrollTop: indiElement.offset().top - dotNavHeight
}, 400);
}
}, 400);
}
else {
// fixed nav scroll
dotDocumentHtml.animate({
scrollTop: indiElement.offset().top - dotNavHeight
}, 700);
}
}
else {
// normal scroll
$('html, body').animate({
scrollTop: $('#' + indiId).offset().top
}, 700);
}
}
else {
`
更具体地说,错误来自此处的 top 属性
` // 正常滚动
$('html, body').animate({
scrollTop: $('#' + indiId).offset().top
}, 700);
`
谁能帮帮我?提前致谢。