Created
October 14, 2019 12:59
-
-
Save imCorfitz/bc8ce1ab2548a0dde0bbd822f7598b93 to your computer and use it in GitHub Desktop.
Transition for Sapper Navigation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import Nav from '../components/Nav.svelte'; | |
import Fly from '../components/Fly.svelte'; | |
export let segment; | |
let active = false; | |
function triggerNav() { | |
active = false; | |
setTimeout(() => {active = true}, 1000); | |
} | |
setTimeout(() => {active = true}, 1000); | |
</script> | |
<style> | |
main { | |
position: relative; | |
max-width: 56em; | |
background-color: white; | |
padding: 2em; | |
margin: 0 auto; | |
box-sizing: border-box; | |
} | |
</style> | |
<Nav on:nav={triggerNav} {segment}/> | |
<main> | |
<Fly {active}> | |
<slot></slot> | |
</Fly> | |
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { fly } from 'svelte/transition'; | |
export let active = false; | |
</script> | |
{#if active} | |
<div transition:fly={{ y: 50, duration: 300 }}> | |
<slot></slot> | |
</div> | |
{/if} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment