This gist was generated by the Svelte REPL. Visit https://svelte.technology/repl?gist=this_gist_id to see it.
Created
August 23, 2017 22:39
-
-
Save anonymous/62220a4ce1a359847b08659136bd86b2 to your computer and use it in GitHub Desktop.
Svelte component
This file contains hidden or 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
<label> | |
<input type='checkbox' bind:checked='visible'> visible | |
</label> | |
{{#if visible}} | |
<div in:fade="{ duration: 300 }" out:fly="{ duration: 300, delay: 300, y: -80 }"> | |
<div class="inner" transition:scale="{ duration: 600 }"></div> | |
</div> | |
{{/if}} | |
<style> | |
.inner { | |
width: 200px; | |
height: 200px; | |
background: red; | |
} | |
</style> | |
<script> | |
import { cubicOut } from 'eases-jsnext'; | |
import { fade, fly } from 'svelte-transitions' | |
export default { | |
transitions: { | |
fly, | |
fade, | |
scale( | |
node, | |
{ delay = 0, duration = 400, easing = cubicOut, initial = 0 } | |
) { | |
const diff = initial - 1; | |
return { | |
delay, | |
duration, | |
easing, | |
css: t => `transform: scale(${initial - (t * diff)});` | |
}; | |
} | |
} | |
}; | |
</script> |
This file contains hidden or 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
{ | |
"name": "world" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment