-
-
Notifications
You must be signed in to change notification settings - Fork 959
Open
Description
Describe the bug
实现聊天记录无限向上滑动,查询更多历史消息,在android或者pc的网页内,体验都正常,在ios的网页里向上滑动很不流畅,一次只能滑动一个item的高度
用的chat-demo的代码,
只改动了两个方法,模拟向上滚动,拼接数据,重新定位scrollTop
async addMessage() {
let pos = this.items.length;
for (let i = 0; i < 20; i++) {
this.items.unshift({
id: id++,
...messages[id % 10000]
});
}
await nextTick();
this.scrollToIndex(pos);
// if (this.streaming) {
// requestAnimationFrame(this.addMessage);
// }
},
scrollToIndex(pos) {
this.$refs.scroller.scrollToItem(pos);
}
Reproduction
Start stream
Stop stream
<input v-model="search" placeholder="Filter..." />
</div>
<DynamicScroller
ref="scroller"
:items="filteredItems"
:min-item-size="54"
class="scroller"
>
<template #before>
<div class="notice">
The message heights are unknown.
</div>
</template>
<template #default="{ item, index, active }">
<DynamicScrollerItem
:item="item"
:active="active"
:size-dependencies="[item.message]"
:data-index="index"
:data-active="active"
:title="`Click to change message ${index}`"
class="message"
@click="changeMessage(item)"
>
<div class="avatar">
<img
:key="item.avatar"
:src="item.avatar"
alt="avatar"
class="image"
/>
</div>
<div class="text">
{{ item.message }}
</div>
<div class="index">
<span>{{ item.id }} (id)</span>
<span>{{ index }} (index)</span>
</div>
</DynamicScrollerItem>
</template>
</DynamicScroller>
System Info
iphone 16 pro max
iphone 14 pro
Used Package Manager
npm
Validations
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
No labels