Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
feat(virtual-scroll): add header and footer slots
Browse files Browse the repository at this point in the history
  • Loading branch information
b2nil committed Oct 24, 2020
1 parent 3c10e6f commit c873efb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/components/virtual-scroll/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,23 @@ const AtVirtualScroll = defineComponent({
}

return () => {
const content = h(View, {
class: 'at-virtual-scroll__container',
style: {
height: convertToUnit((props.items.length * __itemHeight.value)),
}
}, { default: () => getChildren() })

return h(ScrollView, mergeProps(
const content = h(View, null, {
default: () => [
h(View, {
class: 'at-virtual-scroll__container',
style: {
height: convertToUnit((props.items.length * __itemHeight.value)),
}
}, { default: () => getChildren() }),

h(View, {
class: 'at-virtual-scroll__footer'
}, { default: () => slots.footer && slots.footer() }),
]
})


const scrollViewNode = h(ScrollView, mergeProps(
isWeb.value
? {
scrollTop: scrollTop.value
Expand All @@ -190,6 +199,15 @@ const AtVirtualScroll = defineComponent({
onScrollToUpper: props.onReachTop,
onScrollToLower: props.onReachBottom,
}), { default: () => [content] })

return h(View, null, {
default: () => [
h(View, {
class: 'at-virtual-scroll__header',
}, { default: () => slots.header && slots.header() }),
scrollViewNode,
]
})
}
}
})
Expand Down
8 changes: 8 additions & 0 deletions src/style/components/virtual-scroll.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
overflow: auto;
position: relative;

&__header {
display: block;
}

&__container {
display: block;
}

&__footer {
display: block;
}

&__item {
left: 0;
position: absolute;
Expand Down

0 comments on commit c873efb

Please sign in to comment.