dial back rIC usage, fix virtualListStore calculations

This commit is contained in:
Nolan Lawson 2018-03-22 00:01:19 -07:00
parent 72e7e18e0b
commit d2834d3bb2
3 changed files with 9 additions and 14 deletions

View file

@ -23,11 +23,9 @@
let key = this.get('key')
if (makeProps) {
let props = await makeProps(key)
requestAnimationFrame(() => { // delay slightly to avoid slow scrolling
mark('PseudoVirtualListLazyItem set props')
this.set({props: props})
stop('PseudoVirtualListLazyItem set props')
})
mark('PseudoVirtualListLazyItem set props')
this.set({props: props})
stop('PseudoVirtualListLazyItem set props')
}
},
components: {

View file

@ -9,7 +9,6 @@
<script>
import VirtualListItem from './VirtualListItem'
import { mark, stop } from '../../_utils/marks'
import { scheduleIdleTask } from '../../_utils/scheduleIdleTask'
export default {
async oncreate() {
@ -19,11 +18,9 @@
let key = this.get('key')
if (makeProps) {
let props = await makeProps(key)
scheduleIdleTask(() => { // delay slightly to avoid slow scrolling
mark('VirtualListLazyItem set props')
this.set({props: props})
stop('VirtualListLazyItem set props')
})
mark('VirtualListLazyItem set props')
this.set({props: props})
stop('VirtualListLazyItem set props')
}
},
components: {

View file

@ -2,7 +2,7 @@ import { mark, stop } from '../../_utils/marks'
import { RealmStore } from '../../_utils/RealmStore'
import { reselect } from '../../_utils/reselect'
const VIEWPORT_RENDER_FACTOR = 5
const RENDER_BUFFER_FACTOR = 1.5
class VirtualListStore extends RealmStore {
constructor (state) {
@ -30,7 +30,7 @@ virtualListStore.compute('rawVisibleItems',
if (!items) {
return null
}
let renderBuffer = VIEWPORT_RENDER_FACTOR * offsetHeight
let renderBuffer = RENDER_BUFFER_FACTOR * offsetHeight
let visibleItems = []
let totalOffset = showHeader ? headerHeight : 0
let len = items.length
@ -46,7 +46,7 @@ virtualListStore.compute('rawVisibleItems',
continue // above the area we want to render
}
} else {
if (currentOffset > (scrollTop + height + renderBuffer)) {
if (currentOffset > (scrollTop + offsetHeight + renderBuffer)) {
break // below the area we want to render
}
}