Skip to content

Commit

Permalink
fix: Account for the height of the leading and trailing slots when ca…
Browse files Browse the repository at this point in the history
…lculating visible items, fix #685 (#754)
  • Loading branch information
Akryum committed Oct 10, 2022
1 parent a6e07da commit fe72c43
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/demo/src/components/DynamicScrollerDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
The message heights are unknown.
</div>
</template>

<template #after>
<div class="notice">
You have reached the end.
</div>
</template>
<template #default="{ item, index, active }">
<DynamicScrollerItem
:item="item"
Expand Down
14 changes: 14 additions & 0 deletions packages/vue-virtual-scroller/src/components/RecycleScroller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<div
v-if="$slots.before"
class="vue-recycle-scroller__slot"
ref="before"
>
<slot
name="before"
Expand Down Expand Up @@ -43,6 +44,7 @@
<div
v-if="$slots.after"
class="vue-recycle-scroller__slot"
ref="after"
>
<slot
name="after"
Expand Down Expand Up @@ -321,6 +323,18 @@ export default {
scroll.start -= buffer
scroll.end += buffer
// account for leading slot
if (this.$refs.before){
const lead = this.$refs.before.scrollHeight;
scroll.start -= lead;
}
// account for trailing slot
if (this.$refs.after){
const trail = this.$refs.after.scrollHeight;
scroll.end += trail;
}
// Variable size mode
if (itemSize === null) {
let h
Expand Down

0 comments on commit fe72c43

Please sign in to comment.