2018-04-13 04:17:57 +00:00
|
|
|
<div class="virtual-list-header {{shown ? 'shown' : ''}} {{fadedIn ? 'faded-in' : ''}}"
|
2018-02-12 03:15:21 +00:00
|
|
|
ref:node >
|
|
|
|
<:Component {component} :virtualProps />
|
|
|
|
</div>
|
|
|
|
<style>
|
|
|
|
.virtual-list-header {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
width: 100%;
|
|
|
|
opacity: 0;
|
|
|
|
z-index: 10;
|
2018-02-12 06:50:20 +00:00
|
|
|
transition: none;
|
2018-04-13 04:17:57 +00:00
|
|
|
display: none;
|
2018-02-12 03:15:21 +00:00
|
|
|
}
|
|
|
|
.virtual-list-header.shown {
|
2018-04-13 04:17:57 +00:00
|
|
|
display: block;
|
2018-02-12 06:50:20 +00:00
|
|
|
transition: opacity 0.333s linear;
|
2018-02-12 03:15:21 +00:00
|
|
|
}
|
2018-04-13 04:17:57 +00:00
|
|
|
.virtual-list-header.faded-in {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
2018-02-12 03:15:21 +00:00
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
import { virtualListStore } from './virtualListStore'
|
|
|
|
import { AsyncLayout } from '../../_utils/AsyncLayout'
|
2018-04-13 04:17:57 +00:00
|
|
|
import { doubleRAF } from '../../_utils/doubleRAF'
|
2018-02-12 03:15:21 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
oncreate() {
|
2018-04-13 04:17:57 +00:00
|
|
|
this.observe('shown', shown => {
|
|
|
|
if (shown) {
|
|
|
|
this.doCalculateHeight()
|
|
|
|
doubleRAF(() => this.set({fadedIn: true})) // animate in
|
|
|
|
} else {
|
|
|
|
this.set({fadedIn: false})
|
|
|
|
}
|
|
|
|
}, {init: false})
|
2018-02-12 03:15:21 +00:00
|
|
|
},
|
|
|
|
store: () => virtualListStore,
|
2018-04-13 04:17:57 +00:00
|
|
|
methods: {
|
|
|
|
doCalculateHeight() {
|
|
|
|
if (this.get('heightCalculated')) { // only need to calculate once, it never changes
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.set({heightCalculated: true})
|
|
|
|
const asyncLayout = new AsyncLayout(() => '__header__')
|
|
|
|
asyncLayout.observe('__header__', this.refs.node, (rect) => {
|
|
|
|
asyncLayout.disconnect()
|
|
|
|
this.store.setForRealm({headerHeight: rect.height})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2018-02-12 03:15:21 +00:00
|
|
|
}
|
|
|
|
</script>
|