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