forked from cybrespace/pinafore
53 lines
1.4 KiB
HTML
53 lines
1.4 KiB
HTML
<:Window bind:scrollY='scrollY' bind:innerHeight='innerHeight' />
|
|
<div class="virtual-list" ref:node style="height: {{$height}}px;">
|
|
<!-- <div class="virtual-list-viewport" ref:viewport></div> -->
|
|
{{#each $visibleItems as item, virtualIndex}}
|
|
<VirtualListItem :component
|
|
offset="{{item.offset}}"
|
|
props="{{item.item.props}}"
|
|
index="{{item.item.index}}"
|
|
key="{{item.item.key}}"
|
|
/>
|
|
{{/each}}
|
|
</div>
|
|
<style>
|
|
.virtual-list {
|
|
position: relative;
|
|
}
|
|
</style>
|
|
<script>
|
|
import VirtualListItem from './VirtualListItem'
|
|
import { virtualListStore } from '../_utils/virtualListStore'
|
|
|
|
export default {
|
|
oncreate() {
|
|
console.log('scrollHeight', this.refs.node.scrollHeight)
|
|
this.store.set({
|
|
scrollHeight: this.refs.node.scrollHeight,
|
|
})
|
|
this.observe('innerHeight', innerHeight => {
|
|
this.store.set({
|
|
innerHeight: innerHeight
|
|
})
|
|
})
|
|
this.observe('items', (items) => {
|
|
this.store.set({
|
|
'items': items
|
|
})
|
|
})
|
|
this.observe('scrollY', (scrollY) => {
|
|
console.log('scrollY', scrollY)
|
|
this.store.set({
|
|
scrollTop: scrollY
|
|
})
|
|
})
|
|
},
|
|
data: () => ({
|
|
component: null
|
|
}),
|
|
store: () => virtualListStore,
|
|
components: {
|
|
VirtualListItem
|
|
}
|
|
}
|
|
</script> |