break up status rendering with rAF a bit

This commit is contained in:
Nolan Lawson 2018-03-14 18:24:16 -07:00
parent 1477fbfbda
commit c11f2454ad
3 changed files with 23 additions and 9 deletions

View file

@ -13,14 +13,21 @@
{{/if}} {{/if}}
<script> <script>
import PseudoVirtualListItem from './PseudoVirtualListItem.html' import PseudoVirtualListItem from './PseudoVirtualListItem.html'
import { mark, stop } from '../../_utils/marks'
export default { export default {
oncreate() { async oncreate() {
// TODO: there appears to be a bug in {{#await}} that means we have to do this manually. // TODO: there appears to be a bug in {{#await}} that means we have to do this manually.
// Some items may appear on top of other items because their offset is 0 and never updated. // Some items may appear on top of other items because their offset is 0 and never updated.
let makeProps = this.get('makeProps') let makeProps = this.get('makeProps')
let key = this.get('key') let key = this.get('key')
if (makeProps) { if (makeProps) {
makeProps(key).then(props => this.set({props: props})) let props = await makeProps(key)
requestAnimationFrame(() => { // delay slightly to avoid slow scrolling
mark('PseudoVirtualListLazyItem set props')
this.set({props: props})
stop('PseudoVirtualListLazyItem set props')
})
} }
}, },
components: { components: {

View file

@ -74,12 +74,12 @@
detachFullscreenListener(this.onFullscreenChange) detachFullscreenListener(this.onFullscreenChange)
}, },
onScroll(event) { onScroll(event) {
mark('onScroll') let { scrollTop, scrollHeight } = event.target
this.store.setForRealm({ requestAnimationFrame(() => { // delay slightly to improve scroll perf
scrollTop: event.target.scrollTop, mark('onScroll -> setForRealm()')
scrollHeight: event.target.scrollHeight this.store.setForRealm({scrollTop, scrollHeight})
stop('onScroll -> setForRealm()')
}) })
stop('onScroll')
}, },
onFullscreenChange() { onFullscreenChange() {
mark('onFullscreenChange') mark('onFullscreenChange')

View file

@ -8,14 +8,21 @@
{{/if}} {{/if}}
<script> <script>
import VirtualListItem from './VirtualListItem' import VirtualListItem from './VirtualListItem'
import { mark, stop } from '../../_utils/marks'
export default { export default {
oncreate() { async oncreate() {
// TODO: there appears to be a bug in {{#await}} that means we have to do this manually. // TODO: there appears to be a bug in {{#await}} that means we have to do this manually.
// Some items may appear on top of other items because their offset is 0 and never updated. // Some items may appear on top of other items because their offset is 0 and never updated.
let makeProps = this.get('makeProps') let makeProps = this.get('makeProps')
let key = this.get('key') let key = this.get('key')
if (makeProps) { if (makeProps) {
makeProps(key).then(props => this.set({props: props})) let props = await makeProps(key)
requestAnimationFrame(() => { // delay slightly to avoid slow scrolling
mark('VirtualListLazyItem set props')
this.set({props: props})
stop('VirtualListLazyItem set props')
})
} }
}, },
components: { components: {