let scrollInterval: number | null = null;
let userInteracted = false;
const stopScroll = () => {
userInteracted = true;
if (scrollInterval !== null) {
clearInterval(scrollInterval);
scrollInterval = null;
}
};
const handleScroll = () => {
if (userInteracted || !scTop.value) return;
// Start from the current scroll position
let startPosition = scTop.value.scrollTop;
let endPosition = scTop.value.scrollHeight - scTop.value.clientHeight;
let h = 1;
scrollInterval = window.setInterval(() => {
if (userInteracted || h > 1000) {
if (scrollInterval !== null) {
clearInterval(scrollInterval);
scrollInterval = null;
}
return;
}
nextTick(() => {
if (scTop.value) {
scTop.value.scrollTop = startPosition + h * 3;
}
});
h++;
}, 10); // Adjust the interval time for smoother or faster scrolling
};