feat: add preloadItemCount for List, incase we need preload more items before scroll to end

This commit is contained in:
pengfei.zhou
2023-03-09 10:55:32 +08:00
committed by jingpeng
parent 4103704162
commit 0774df96e1
26 changed files with 4495 additions and 2639 deletions

View File

@@ -20,8 +20,8 @@ async function loadData(offset: number): Promise<{
}>(resolve => {
setTimeout(() => {
resolve({
isEnd: offset > 100,
data: new Array(5).fill(offset).map((e, idx) => {
isEnd: offset > 1000,
data: new Array(15).fill(offset).map((e, idx) => {
return { text: `Item: ${e + idx}` }
})
})
@@ -65,6 +65,7 @@ class ListVH extends ViewHolder {
class ListVM extends ViewModel<ListModel, ListVH> {
onAttached(state: ListModel, vh: ListVH) {
vh.list.apply({
preloadItemCount: 5,
canDrag: true,
onDragging: (from, to) => {
log(`onDragging, from: ${from}, to: ${to}`)
@@ -127,7 +128,14 @@ class ListVM extends ViewModel<ListModel, ListVH> {
loge('completelyVisible Items is:', ret)
const ret2 = await vh.list.findVisibleItems(context)
loge('visible Items is:', ret2)
}
},
loadMoreView: listItem(text({
text: "LoadMore",
}), {
layoutConfig: layoutConfig().mostWidth().justHeight(),
height: 30,
backgroundColor: Color.YELLOW,
})
})
loadData(state.offset).then(ret => {
this.updateState(state => {