spoiler button is faster now
This commit is contained in:
parent
d682982a54
commit
c67ba5c0a9
|
@ -55,11 +55,13 @@
|
|||
},
|
||||
methods: {
|
||||
onClickSpoilerButton() {
|
||||
requestAnimationFrame(() => {
|
||||
let uuid = this.get('uuid')
|
||||
let $spoilersShown = this.store.get('spoilersShown')
|
||||
$spoilersShown[uuid] = !$spoilersShown[uuid]
|
||||
this.store.set({'spoilersShown': $spoilersShown})
|
||||
this.fire('recalculateHeight')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,14 +28,6 @@
|
|||
|
||||
export default {
|
||||
oncreate() {
|
||||
this.doRecalculateHeight()
|
||||
},
|
||||
store: () => virtualListStore,
|
||||
computed: {
|
||||
'shown': ($itemHeights, key) => $itemHeights[key] > 0
|
||||
},
|
||||
methods: {
|
||||
doRecalculateHeight() {
|
||||
let asyncLayout = new AsyncLayout(node => node.getAttribute('virtual-list-key'))
|
||||
let key = this.get('key')
|
||||
asyncLayout.observe(key, this.refs.node, (rect) => {
|
||||
|
@ -43,6 +35,20 @@
|
|||
// update all item heights in one batch for better perf
|
||||
this.store.batchUpdateForRealm('itemHeights', key, rect.height)
|
||||
})
|
||||
},
|
||||
store: () => virtualListStore,
|
||||
computed: {
|
||||
'shown': ($itemHeights, key) => $itemHeights[key] > 0
|
||||
},
|
||||
methods: {
|
||||
doRecalculateHeight() {
|
||||
// Recalculate immediately because this is done on-demand, e.g.
|
||||
// when clicking the "More" button on a spoiler.
|
||||
let rect = this.refs.node.getBoundingClientRect()
|
||||
let key = this.get('key')
|
||||
let itemHeights = this.store.get('itemHeights')
|
||||
itemHeights[key] = rect.height
|
||||
this.store.setForRealm({itemHeights})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue