Browse Source

取消无操作2秒后自动滚动;解决手动滚动和自动滚动冲突;

dev
宋杰 10 hours ago
parent
commit
239f218a1d
  1. 27
      src/views/AiEmotion.vue
  2. 8
      src/views/homePage.vue

27
src/views/AiEmotion.vue

@ -669,6 +669,8 @@ const hasTriggeredTypewriter = ref(false); // 是否已触发打字机效果
const intersectionObserver = ref(null); // observer const intersectionObserver = ref(null); // observer
const isUserInitiated = ref(false); // const isUserInitiated = ref(false); //
const shouldEnableAutoScroll = ref(false); // true const shouldEnableAutoScroll = ref(false); // true
const isUserScrolling = ref(false); //
const userScrollTimer = ref(null); //
// 使parsedConclusion // 使parsedConclusion
@ -2838,9 +2840,21 @@ function renderCharts(data) {
// scrollToBottom // scrollToBottom
//
//
const handleUserScroll = () => { const handleUserScroll = () => {
//
//
isUserScrolling.value = true;
//
if (userScrollTimer.value) {
clearTimeout(userScrollTimer.value);
}
// 2
userScrollTimer.value = setTimeout(() => {
isUserScrolling.value = false;
console.log("用户滚动检测:恢复自动滚动");
}, 2000);
}; };
// //
@ -3012,7 +3026,8 @@ const debouncedScrollToBottom = (() => {
clearTimeout(timeoutId); clearTimeout(timeoutId);
} }
timeoutId = setTimeout(() => { timeoutId = setTimeout(() => {
if (isAutoScrollEnabled.value && isPageLoaded.value) {
//
if (isAutoScrollEnabled.value && isPageLoaded.value && !isUserScrolling.value) {
scrollToBottom(); scrollToBottom();
} }
}, 150); }, 150);
@ -3301,6 +3316,12 @@ onUnmounted(() => {
// //
stopHeightObserver(); stopHeightObserver();
//
if (userScrollTimer.value) {
clearTimeout(userScrollTimer.value);
userScrollTimer.value = null;
}
// Intersection Observer // Intersection Observer
if (intersectionObserver.value) { if (intersectionObserver.value) {
intersectionObserver.value.disconnect(); intersectionObserver.value.disconnect();

8
src/views/homePage.vue

@ -494,10 +494,10 @@ const handleAiEmotionUserScroll = () => {
} }
// 2 // 2
aiEmotionScrollTimer.value = setTimeout(() => {
isAiEmotionUserScrolling.value = false;
console.log("AiEmotion页面用户滚动检测:恢复自动滚动");
}, 2000);
// aiEmotionScrollTimer.value = setTimeout(() => {
// isAiEmotionUserScrolling.value = false;
// console.log("AiEmotion");
// }, 2000);
}; };
// AiEmotion // AiEmotion

Loading…
Cancel
Save