Akryum / Akryum/vue-virtual-scroller

scrollbar not updating when data is added (Vue 3)

Open
#692 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
10.8k
Forks
973
PR merge metrics
No merged PRs in 30d

Description

I'm trying to implement infinite loading the issue is that even after the data is added I can't scroll further until I scroll up a bit then its being refreshed.
here's a reproduction of the issue

I'm using
`"vue-virtual-scroller": "^2.0.0-alpha.1"`

this is my component

```


data count: {{ data.length }}

{{ item }}

import { defineComponent, ref } from 'vue';

interface record {
id: number;
name: string;
}

function generateData(startIndex: number): Array<record> {
const arr = Array<record>();
for (let i = startIndex; i < startIndex + 10; i += 1) {
arr.push({
id: i,
name: `${i} index`,
});
}
return arr;
}

export default defineComponent({
setup() {
const data = ref(generateData(0));

const handleScroll = async function ({ target }: { target: HTMLElement }) {
const { scrollTop, scrollHeight, offsetHeight } = target;

if (scrollTop === scrollHeight - offsetHeight) {
data.value.push(...generateData(data.value.length - 1));
}
};
return {
data,
handleScroll,
};
},
});

.list {
height: 200px;
}

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.