fix empty timelines
This commit is contained in:
parent
27858e32f8
commit
8af2e2061f
|
@ -63,7 +63,7 @@ export function initializeTimeline() {
|
||||||
|
|
||||||
export async function setupTimeline() {
|
export async function setupTimeline() {
|
||||||
mark('setupTimeline')
|
mark('setupTimeline')
|
||||||
if (!store.get('timelineItemIds').length) {
|
if (!store.get('timelineItemIds')) {
|
||||||
await fetchTimelineItemsAndPossiblyFallBack()
|
await fetchTimelineItemsAndPossiblyFallBack()
|
||||||
}
|
}
|
||||||
stop('setupTimeline')
|
stop('setupTimeline')
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
<div class="pseudo-virtual-list {{shown ? '' : 'hidden'}}" on:initializedVisibleItems ref:node>
|
<div class="pseudo-virtual-list {{shown ? '' : 'hidden'}}" on:initializedVisibleItems ref:node>
|
||||||
{{#each wrappedItems as wrappedItem, i @item}}
|
{{#if wrappedItems}}
|
||||||
<PseudoVirtualListLazyItem
|
{{#each wrappedItems as wrappedItem, i @item}}
|
||||||
component="{{component}}"
|
<PseudoVirtualListLazyItem
|
||||||
index="{{i}}"
|
component="{{component}}"
|
||||||
length="{{wrappedItems.length}}"
|
index="{{i}}"
|
||||||
makeProps="{{makeProps}}"
|
length="{{wrappedItems.length}}"
|
||||||
key="{{wrappedItem.item}}"
|
makeProps="{{makeProps}}"
|
||||||
intersectionObserver="{{intersectionObserver}}"
|
key="{{wrappedItem.item}}"
|
||||||
isIntersecting="{{isIntersecting(wrappedItem.item, $intersectionStates)}}"
|
intersectionObserver="{{intersectionObserver}}"
|
||||||
isCached="{{isCached(wrappedItem.item, $intersectionStates)}}"
|
isIntersecting="{{isIntersecting(wrappedItem.item, $intersectionStates)}}"
|
||||||
height="{{getHeight(wrappedItem.item, $intersectionStates)}}"
|
isCached="{{isCached(wrappedItem.item, $intersectionStates)}}"
|
||||||
/>
|
height="{{getHeight(wrappedItem.item, $intersectionStates)}}"
|
||||||
{{/each}}
|
/>
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<style>
|
<style>
|
||||||
.pseudo-virtual-list {
|
.pseudo-virtual-list {
|
||||||
|
@ -114,9 +116,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
wrappedItems: (items) => items.map(item => ({item: item})),
|
wrappedItems: (items) => items && items.map(item => ({item: item})),
|
||||||
allItemsHaveHeight: (items, $intersectionStates) => {
|
allItemsHaveHeight: (items, $intersectionStates) => {
|
||||||
if (!items.length) {
|
if (!items) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for (let item of items) {
|
for (let item of items) {
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initialize() {
|
initialize() {
|
||||||
if (this.store.get('initialized') || !this.store.get('timelineItemIds') || !this.store.get('timelineItemIds').length) {
|
if (this.store.get('initialized') || !this.store.get('timelineItemIds')) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('timeline initialize()')
|
console.log('timeline initialize()')
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
<!-- TODO: setting height is hacky, just make this element the scroller -->
|
<!-- TODO: setting height is hacky, just make this element the scroller -->
|
||||||
<div class="virtual-list {{shown ? '' : 'hidden'}}" style="height: {{$height}}px;">
|
<div class="virtual-list {{shown ? '' : 'hidden'}}" style="height: {{$height}}px;">
|
||||||
{{#each $visibleItems as visibleItem @key}}
|
{{#if $visibleItems}}
|
||||||
<VirtualListLazyItem :component
|
{{#each $visibleItems as visibleItem @key}}
|
||||||
offset="{{visibleItem.offset}}"
|
<VirtualListLazyItem :component
|
||||||
makeProps="{{makeProps}}"
|
offset="{{visibleItem.offset}}"
|
||||||
key="{{visibleItem.key}}"
|
makeProps="{{makeProps}}"
|
||||||
index="{{visibleItem.index}}"
|
key="{{visibleItem.key}}"
|
||||||
/>
|
index="{{visibleItem.index}}"
|
||||||
{{/each}}
|
/>
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
{{#if $showFooter}}
|
{{#if $showFooter}}
|
||||||
<VirtualListFooter component="{{footerComponent}}"/>
|
<VirtualListFooter component="{{footerComponent}}"/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -11,7 +11,7 @@ class VirtualListStore extends RealmStore {
|
||||||
|
|
||||||
const virtualListStore = new VirtualListStore()
|
const virtualListStore = new VirtualListStore()
|
||||||
|
|
||||||
virtualListStore.computeForRealm('items', [])
|
virtualListStore.computeForRealm('items', null)
|
||||||
virtualListStore.computeForRealm('showFooter', false)
|
virtualListStore.computeForRealm('showFooter', false)
|
||||||
virtualListStore.computeForRealm('footerHeight', 0)
|
virtualListStore.computeForRealm('footerHeight', 0)
|
||||||
virtualListStore.computeForRealm('scrollTop', 0)
|
virtualListStore.computeForRealm('scrollTop', 0)
|
||||||
|
@ -23,6 +23,9 @@ virtualListStore.compute('visibleItems',
|
||||||
['items', 'scrollTop', 'itemHeights', 'offsetHeight'],
|
['items', 'scrollTop', 'itemHeights', 'offsetHeight'],
|
||||||
(items, scrollTop, itemHeights, offsetHeight) => {
|
(items, scrollTop, itemHeights, offsetHeight) => {
|
||||||
mark('compute visibleItems')
|
mark('compute visibleItems')
|
||||||
|
if (!items) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
let renderBuffer = VIEWPORT_RENDER_FACTOR * offsetHeight
|
let renderBuffer = VIEWPORT_RENDER_FACTOR * offsetHeight
|
||||||
let visibleItems = []
|
let visibleItems = []
|
||||||
let totalOffset = 0
|
let totalOffset = 0
|
||||||
|
@ -56,6 +59,9 @@ virtualListStore.compute('visibleItems',
|
||||||
virtualListStore.compute('heightWithoutFooter',
|
virtualListStore.compute('heightWithoutFooter',
|
||||||
['items', 'itemHeights'],
|
['items', 'itemHeights'],
|
||||||
(items, itemHeights) => {
|
(items, itemHeights) => {
|
||||||
|
if (!items) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
let sum = 0
|
let sum = 0
|
||||||
let i = -1
|
let i = -1
|
||||||
let len = items.length
|
let len = items.length
|
||||||
|
@ -77,7 +83,7 @@ virtualListStore.compute('length', ['items'], (items) => items ? items.length :
|
||||||
virtualListStore.compute('allVisibleItemsHaveHeight',
|
virtualListStore.compute('allVisibleItemsHaveHeight',
|
||||||
['visibleItems', 'itemHeights'],
|
['visibleItems', 'itemHeights'],
|
||||||
(visibleItems, itemHeights) => {
|
(visibleItems, itemHeights) => {
|
||||||
if (!visibleItems.length) {
|
if (!visibleItems) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for (let visibleItem of visibleItems) {
|
for (let visibleItem of visibleItems) {
|
||||||
|
|
|
@ -4,8 +4,8 @@ export function timelineComputations(store) {
|
||||||
return ((timelines && timelines[currentInstance]) || {})[currentTimeline] || {}
|
return ((timelines && timelines[currentInstance]) || {})[currentTimeline] || {}
|
||||||
})
|
})
|
||||||
|
|
||||||
store.compute('timelineItemIds', ['currentTimelineData'], (currentTimelineData) => currentTimelineData.timelineItemIds || [])
|
store.compute('timelineItemIds', ['currentTimelineData'], (currentTimelineData) => currentTimelineData.timelineItemIds)
|
||||||
store.compute('runningUpdate', ['currentTimelineData'], (currentTimelineData) => currentTimelineData.runningUpdate)
|
store.compute('runningUpdate', ['currentTimelineData'], (currentTimelineData) => currentTimelineData.runningUpdate)
|
||||||
store.compute('initialized', ['currentTimelineData'], (currentTimelineData) => currentTimelineData.initialized)
|
store.compute('initialized', ['currentTimelineData'], (currentTimelineData) => currentTimelineData.initialized)
|
||||||
store.compute('lastTimelineItemId', ['timelineItemIds'], (timelineItemIds) => timelineItemIds.length && timelineItemIds[timelineItemIds.length - 1])
|
store.compute('lastTimelineItemId', ['timelineItemIds'], (timelineItemIds) => timelineItemIds && timelineItemIds.length && timelineItemIds[timelineItemIds.length - 1])
|
||||||
}
|
}
|
Loading…
Reference in New Issue