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
1 changed files with 28 additions and 1 deletions

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}`} >
<svelte:component this={component}
virtualProps={props}
@ -7,3 +20,17 @@
virtualKey={key}
/>
</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>