fix: ListItem should have proper fade animations (#1771)

This commit is contained in:
Nolan Lawson 2020-05-14 21:22:33 -07:00 committed by GitHub
parent f5eb5fc50b
commit c610a259d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,17 @@
<div class="list-item" <style>
.list-item {
opacity: 0;
pointer-events: none;
transition: opacity 0.2s linear;
contain: content; /* see https://www.w3.org/TR/2018/CR-css-contain-1-20181108/#valdef-contain-content */
}
.list-item.shown {
opacity: 1;
pointer-events: auto;
}
</style>
<div class="list-item {shown && 'shown'}"
id={`list-item-${key}`} > id={`list-item-${key}`} >
<svelte:component this={component} <svelte:component this={component}
virtualProps={props} virtualProps={props}
@ -7,3 +20,17 @@
virtualKey={key} virtualKey={key}
/> />
</div> </div>
<script>
import { doubleRAF } from '../../_utils/doubleRAF'
export default {
oncreate () {
doubleRAF(() => {
this.set({ shown: true }) // ensure fade-in animation happens after rAF
})
},
data: () => ({
shown: false
})
}
</script>