Skip to content

Commit 2879fa2

Browse files
committed
fix: correct scroll to bottom on mounth
1 parent 53efc5a commit 2879fa2

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

custom/CustomAutoScrollContainer.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</template>
1212

1313
<script setup lang="ts">
14-
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
14+
import { ref, onMounted, onUnmounted, nextTick, watch } from 'vue'
1515
import CustomScrollbar from 'custom-vue-scrollbar';
1616
import 'custom-vue-scrollbar/dist/style.css';
1717
import { useAgentStore } from './composables/useAgentStore';
@@ -50,7 +50,6 @@ function scrollToBottom(force = false): void {
5050
if (!container) return
5151
5252
if (isUserScrolledUp.value && !force) return
53-
5453
container.scrollTo({
5554
top: container.scrollHeight,
5655
behavior: props.behavior
@@ -65,7 +64,7 @@ function hasScrollbar(): boolean {
6564
}
6665
6766
68-
function handleScroll(): void {
67+
function handleScroll(detectScrollDown = true): void {
6968
const container = containerRef.value.scrollEl
7069
if (!container) return
7170
@@ -80,12 +79,10 @@ function handleScroll(): void {
8079
isUserScrolledUp.value = false
8180
} else {
8281
const isScrollingUp = scrollTop < lastScrollTop
83-
const isScrollingDown = scrollTop > lastScrollTop
82+
const isScrollingDown = detectScrollDown ? scrollTop > lastScrollTop : false
8483
const isContentUnchanged = scrollHeight === lastScrollHeight
8584
if ((isScrollingUp || isScrollingDown) && isContentUnchanged) {
8685
isUserScrolledUp.value = true
87-
} else if (!isNearBottom()) {
88-
isUserScrolledUp.value = true
8986
}
9087
}
9188
lastScrollTop = scrollTop
@@ -110,7 +107,6 @@ onMounted(() => {
110107
}
111108
112109
lastScrollHeight = containerRef.value.scrollEl.scrollHeight
113-
114110
if (props.enabled && !isUserScrolledUp.value) {
115111
scrollToBottom()
116112
}

custom/conversation_area/ConversationArea.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ const showScrollToBottomButton = ref(false);
8383
const innerScrollContainerRef = ref(null);
8484
const agentStore = useAgentStore();
8585
const agentTransitions = useAgentTransitions();
86-
const clicks = ref(0);
8786
const showScrollContainer = ref(true);
8887
8988
function recalculateScroll() {
9089
if (scrollContainer.value) {
91-
scrollContainer.value.handleScroll();
90+
scrollContainer.value.handleScroll(false);
9291
const isScrolledUp = scrollContainer.value.isUserScrolledUp();
9392
showScrollToBottomButton.value = !!isScrolledUp;
9493
}
@@ -121,9 +120,6 @@ watch(scrollContainer, () => {
121120
}
122121
})
123122
124-
watch(clicks, () => {
125-
recalculateScroll();
126-
})
127123
128124
129125
</script>

0 commit comments

Comments
 (0)