1111</template >
1212
1313<script setup lang="ts">
14- import { ref , onMounted , onUnmounted , nextTick , watch } from ' vue'
14+ import { ref , onMounted , onUnmounted , nextTick , computed } from ' vue'
1515import CustomScrollbar from ' custom-vue-scrollbar' ;
1616import ' custom-vue-scrollbar/dist/style.css' ;
1717import { useAgentStore } from ' ./composables/useAgentStore' ;
1818
19- const agentStore = useAgentStore ();
19+ const scrollParams = ref ({
20+ scrollTop: 0 ,
21+ scrollHeight: 0 ,
22+ clientHeight: 0
23+ });
2024
2125const props = withDefaults (defineProps <{
2226 enabled? : boolean
@@ -42,6 +46,9 @@ function isNearBottom(): boolean {
4246 if (! container ) return true
4347
4448 const { scrollTop, scrollHeight, clientHeight } = container
49+ scrollParams .value .scrollTop = scrollTop
50+ scrollParams .value .scrollHeight = scrollHeight
51+ scrollParams .value .clientHeight = clientHeight
4552 return scrollHeight - scrollTop - clientHeight <= props .threshold
4653}
4754
@@ -107,6 +114,9 @@ onMounted(() => {
107114 }
108115
109116 lastScrollHeight = containerRef .value .scrollEl .scrollHeight
117+ scrollParams .value .scrollTop = containerRef .value .scrollEl .scrollTop
118+ scrollParams .value .scrollHeight = containerRef .value .scrollEl .scrollHeight
119+ scrollParams .value .clientHeight = containerRef .value .scrollEl .clientHeight
110120 if (props .enabled && ! isUserScrolledUp .value ) {
111121 scrollToBottom ()
112122 }
@@ -128,7 +138,8 @@ defineExpose({
128138 scrollToBottom : () => scrollToBottom (true ),
129139 isUserScrolledUp : () => isUserScrolledUp .value ,
130140 container: containerRef ,
131- handleScroll
141+ handleScroll ,
142+ scrollParams
132143})
133144 </script >
134145
0 commit comments