fix(VirtualList): fix some TODOs (#1851)
* fix(VirtualList): fix some TODOs * fix: fix memory leak * fix: remove dead code
This commit is contained in:
parent
4d1a72bb98
commit
40e9b44adc
|
@ -64,6 +64,8 @@
|
|||
this.store.setForRealm({ items: newItems })
|
||||
stop('set items')
|
||||
})
|
||||
// We observe on the component rather than the store to avoid a leak in store listeners
|
||||
// (Svelte automatically removes component listeners, but not store listeners)
|
||||
this.observe('allVisibleItemsHaveHeight', allVisibleItemsHaveHeight => {
|
||||
this.calculateListOffset()
|
||||
if (allVisibleItemsHaveHeight) {
|
||||
|
@ -71,18 +73,12 @@
|
|||
}
|
||||
})
|
||||
|
||||
let observedOnce = false
|
||||
|
||||
this.observe('distanceFromBottom', (distanceFromBottom) => {
|
||||
if (!observedOnce) {
|
||||
observedOnce = true // TODO: the first time is always 0... need better way to handle this
|
||||
return
|
||||
}
|
||||
if (distanceFromBottom >= 0 &&
|
||||
distanceFromBottom <= DISTANCE_FROM_BOTTOM_TO_FIRE) {
|
||||
this.fireScrollToBottom()
|
||||
}
|
||||
})
|
||||
}, { init: false })
|
||||
|
||||
this.observe('scrollTop', (scrollTop) => {
|
||||
this.fire('scrollTopChanged', scrollTop)
|
||||
|
@ -107,7 +103,6 @@
|
|||
return $scrollHeight - $scrollTop - $offsetHeight
|
||||
},
|
||||
scrollTop: ({ $scrollTop }) => $scrollTop,
|
||||
// TODO: bug in svelte store, shouldn't need to do this
|
||||
allVisibleItemsHaveHeight: ({ $allVisibleItemsHaveHeight }) => $allVisibleItemsHaveHeight,
|
||||
visibleItemKeys: ({ $visibleItems }) => ($visibleItems || []).map(_ => _.key)
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue