2018-01-16 01:12:07 +01:00
|
|
|
<:Window bind:scrollY='scrollY' bind:innerHeight='innerHeight' />
|
2018-01-15 21:23:28 +01:00
|
|
|
<div class="virtual-list" ref:node style="height: {{$height}}px;">
|
|
|
|
<!-- <div class="virtual-list-viewport" ref:viewport></div> -->
|
2018-01-16 01:12:07 +01:00
|
|
|
{{#each $visibleItems as item, virtualIndex}}
|
2018-01-15 19:54:02 +01:00
|
|
|
<VirtualListItem :component
|
2018-01-16 01:12:07 +01:00
|
|
|
offset="{{item.offset}}"
|
|
|
|
props="{{item.item.props}}"
|
|
|
|
index="{{item.item.index}}"
|
|
|
|
key="{{item.item.key}}"
|
2018-01-15 21:23:28 +01:00
|
|
|
/>
|
2018-01-15 19:54:02 +01:00
|
|
|
{{/each}}
|
|
|
|
</div>
|
|
|
|
<style>
|
|
|
|
.virtual-list {
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
import VirtualListItem from './VirtualListItem'
|
2018-01-15 21:23:28 +01:00
|
|
|
import { virtualListStore } from '../_utils/virtualListStore'
|
2018-01-15 19:54:02 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
oncreate() {
|
2018-01-16 01:12:07 +01:00
|
|
|
console.log('scrollHeight', this.refs.node.scrollHeight)
|
|
|
|
this.store.set({
|
|
|
|
scrollHeight: this.refs.node.scrollHeight,
|
|
|
|
})
|
|
|
|
this.observe('innerHeight', innerHeight => {
|
|
|
|
this.store.set({
|
|
|
|
innerHeight: innerHeight
|
|
|
|
})
|
|
|
|
})
|
2018-01-15 21:23:28 +01:00
|
|
|
this.observe('items', (items) => {
|
2018-01-16 01:12:07 +01:00
|
|
|
this.store.set({
|
|
|
|
'items': items
|
|
|
|
})
|
2018-01-15 19:54:02 +01:00
|
|
|
})
|
2018-01-15 21:23:28 +01:00
|
|
|
this.observe('scrollY', (scrollY) => {
|
|
|
|
console.log('scrollY', scrollY)
|
2018-01-16 01:12:07 +01:00
|
|
|
this.store.set({
|
|
|
|
scrollTop: scrollY
|
|
|
|
})
|
2018-01-15 19:54:02 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
data: () => ({
|
2018-01-15 21:23:28 +01:00
|
|
|
component: null
|
2018-01-15 19:54:02 +01:00
|
|
|
}),
|
2018-01-15 21:23:28 +01:00
|
|
|
store: () => virtualListStore,
|
2018-01-15 19:54:02 +01:00
|
|
|
components: {
|
|
|
|
VirtualListItem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|