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'
1515import CustomScrollbar from ' custom-vue-scrollbar' ;
1616import ' custom-vue-scrollbar/dist/style.css' ;
1717import { 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 }
0 commit comments