-
-
Notifications
You must be signed in to change notification settings - Fork 969
Closed
Description
Describe the bug
A call to scrollToItem require the user to set a value for gridItems:
vue-virtual-scroller/packages/vue-virtual-scroller/src/components/RecycleScroller.vue
Lines 681 to 689 in 86fa98f
| scrollToItem (index) { | |
| let scroll | |
| if (this.itemSize === null) { | |
| scroll = index > 0 ? this.sizes[index - 1].accumulator : 0 | |
| } else { | |
| scroll = Math.floor(index / this.gridItems) * this.itemSize | |
| } | |
| this.scrollToPosition(scroll) | |
| }, |
Doing so, the library set a width to the items in px and that is by default the same as the itemSize:
This breaks list where the item width is 100%
Reproduction
<template>
<div id="app">
<RecycleScroller
:items="items"
v-slot="{ item }"
:grid-items="1"
:item-size="20"
>
<div height="20">{{ item.id }} This takes more than 20px witdh</div>
</RecycleScroller>
</div>
</template>
<script>
export default {
setup() {
return {
items: [...Array(1000).keys()].map((x) => ({ id: x })),
};
},
};
</script>
https://stackblitz.com/edit/vue-zcyqsm?file=src/App.vue
System Info
NA (stackblitz)Used Package Manager
yarn
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