here is my code
const target = document.querySelector(eventTarget);
const targetPosition = target.getBoundingClientRect();
const startPosition = window.pageYoffset;
const distance = targetPosition - startPosition;
const startTime = null;
function animation(currentTime) {
if(startTime === null )
startTime = currentTime;
const timeElapsed = currentTime - startTime
const run = ease(timeElapsed, startPosition, distance, duration);
}
function ease(t,b,c,d) {
t /= d / 2;
if (t < 1) return c / 2 * t * t + b;
t--;
return -c / 2 * (t * (t-2) - 1) + b;
}
requestAnimationFrame(animation);
}
const clickScroll = () => {
const button = document.getElementById(".button");
button.addEventListener("click", () => {
smoothScroll(".second", 1000);
});
}
export { smoothScroll, clickScroll };
So based on the console, the target = document.querySelector(eventTarget); failed to work and thus it is null. please help to debug the hack and shed light on the bug