Skip to content

Commit d4ae5ab

Browse files
authoredJun 7, 2024··
feat(applet): auto scroll to bottom when timeline event updated (#430)
1 parent a9801ea commit d4ae5ab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

Diff for: ‎packages/applet/src/components/timeline/EventList.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import type { TimelineEventOptions } from '@vue/devtools-kit'
3-
import { computed } from 'vue'
3+
import { computed, ref, watch } from 'vue'
44
import { RecycleScroller } from 'vue-virtual-scroller'
55
import { formatTime } from '~/utils'
66
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
@@ -11,6 +11,7 @@ const props = defineProps<{
1111
1212
const selected = defineModel()
1313
const colors = ['#3e5770', '#42b983', '#0098c4']
14+
const scrollerRef = ref<InstanceType<typeof RecycleScroller> | null>(null)
1415
1516
const normalizedData = computed(() => {
1617
let currentColorIndex = -1
@@ -26,11 +27,16 @@ const normalizedData = computed(() => {
2627
})
2728
return props.data
2829
})
30+
31+
watch(() => normalizedData.value.length, (length) => {
32+
scrollerRef.value?.scrollToItem(length - 1)
33+
}, { flush: 'post' })
2934
</script>
3035

3136
<template>
3237
<div class="p3">
3338
<RecycleScroller
39+
ref="scrollerRef"
3440
v-slot="{ item }"
3541
:items="normalizedData"
3642
:min-item-size="52"

0 commit comments

Comments
 (0)
Please sign in to comment.