pinafore/src/routes/_components/LazyPage.html

26 lines
843 B
HTML
Raw Normal View History

{#if revealed}
<svelte:component this={pageComponent} {params} />
{/if}
<script>
import { doubleRAF } from '../_utils/doubleRAF'
// On the very first page load, avoid doing a "reveal" because
// it leads to a flash between when the SSR is shown, the two frame we hide it,
// and then when we show it again.
//
// We only really need LazyPage behavior when the user is clicking around
// after the page has loaded, to improve input responsiveness.
let firstTime = true
export default {
2018-04-20 04:38:01 +00:00
oncreate () {
firstTime = false
// Yes, triple raf. This is to ensure the NavItem animation plays before we
// start rendering the new page.
doubleRAF(() => requestAnimationFrame(() => this.set({ revealed: true })))
},
data: () => ({
revealed: !process.browser || firstTime
})
}
</script>