pinafore/routes/_components/timeline/LazyTimeline.html
2018-01-28 12:51:48 -08:00

58 lines
1.4 KiB
HTML

<div class="lazy-timeline">
{{#if !$initialized}}
<!-- <div transition:fade> -->
<div class="loading-page">
<LoadingSpinner />
</div>
<!-- </div> -->
{{/if}}
{{#await promise}}
{{then constructor}}
<:Component {constructor} :timeline />
{{catch error}}
<div>Component failed to load. Please try refreshing! {{error}}</div>
{{/await}}
</div>
<style>
.lazy-timeline {
width: 100%;
min-height: 60vh;
}
.loading-page {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: flex;
align-items: center;
justify-content: center;
z-index: 50
}
</style>
<script>
import { importTimeline } from '../../_utils/asyncModules'
import LoadingSpinner from '../LoadingSpinner.html'
// TODO: the transition seems to occasionally cause an error in Svelte, transition_run is undefined
//import { fade } from 'svelte-transitions'
import { store } from '../../_utils/store'
export default {
oncreate() {
let instanceName = this.store.get('currentInstance')
let timeline = this.get('timeline')
this.store.set({currentTimeline: timeline})
this.store.setForTimeline(instanceName, timeline, {runningUpdate: false})
},
store: () => store,
data: () => ({
promise: importTimeline()
}),
components: {
LoadingSpinner
}/*,
transitions: {
fade
}*/
}
</script>