simplify virtual list even more
This commit is contained in:
		
							parent
							
								
									5f12322ac8
								
							
						
					
					
						commit
						b15ad4b2f7
					
				
					 3 changed files with 7 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
<div class="timeline" role="feed" aria-label="{{label}}" on:initialized>
 | 
			
		||||
  <VirtualList component="{{StatusListItem}}"
 | 
			
		||||
               :makeProps
 | 
			
		||||
               :items
 | 
			
		||||
               items="{{statusIds}}"
 | 
			
		||||
               on:scrollToBottom="onScrollToBottom()"
 | 
			
		||||
               shown="{{initialized}}"
 | 
			
		||||
               footerComponent="{{LoadingFooter}}"
 | 
			
		||||
| 
						 | 
				
			
			@ -49,11 +49,6 @@
 | 
			
		|||
    }),
 | 
			
		||||
    computed: {
 | 
			
		||||
      makeProps: ($currentInstance) => (statusId) => database.getStatus($currentInstance, statusId),
 | 
			
		||||
      items: (statusIds) => {
 | 
			
		||||
        return statusIds.map(statusId => ({
 | 
			
		||||
          key: statusId
 | 
			
		||||
        }))
 | 
			
		||||
      },
 | 
			
		||||
      lastStatusId: (statusIds) => statusIds.length && statusIds[statusIds.length - 1],
 | 
			
		||||
      label: (timeline, $currentInstance) => {
 | 
			
		||||
        if (timelines[timeline]) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,11 @@
 | 
			
		|||
<!-- TODO: setting height is hacky, just make this element the scroller -->
 | 
			
		||||
<div class="virtual-list {{shown ? '' : 'hidden'}}" style="height: {{$height}}px;">
 | 
			
		||||
  {{#each $visibleItems as item @key}}
 | 
			
		||||
  {{#each $visibleItems as visibleItem @key}}
 | 
			
		||||
    <VirtualListLazyItem :component
 | 
			
		||||
                         offset="{{item.offset}}"
 | 
			
		||||
                         offset="{{visibleItem.offset}}"
 | 
			
		||||
                         makeProps="{{makeProps}}"
 | 
			
		||||
                         key="{{item.key}}"
 | 
			
		||||
                         index="{{item.index}}"
 | 
			
		||||
                         key="{{visibleItem.key}}"
 | 
			
		||||
                         index="{{visibleItem.index}}"
 | 
			
		||||
    />
 | 
			
		||||
  {{/each}}
 | 
			
		||||
  {{#if $showFooter}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ virtualListStore.compute('visibleItems',
 | 
			
		|||
  let len = items.length
 | 
			
		||||
  let i = -1
 | 
			
		||||
  while (++i < len) {
 | 
			
		||||
    let { key } = items[i]
 | 
			
		||||
    let key = items[i]
 | 
			
		||||
    let height = itemHeights[key] || 0
 | 
			
		||||
    let currentOffset = totalOffset
 | 
			
		||||
    totalOffset += height
 | 
			
		||||
| 
						 | 
				
			
			@ -87,7 +87,7 @@ virtualListStore.compute('heightWithoutFooter',
 | 
			
		|||
  let i = -1
 | 
			
		||||
  let len = items.length
 | 
			
		||||
  while (++i < len) {
 | 
			
		||||
    sum += itemHeights[items[i].key] || 0
 | 
			
		||||
    sum += itemHeights[items[i]] || 0
 | 
			
		||||
  }
 | 
			
		||||
  return sum
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue