Skip to content

Instantly share code, notes, and snippets.

@silentworks
Forked from anonymous/App.html
Created September 5, 2017 15:26
Show Gist options
  • Save silentworks/7ecc31a9e1ea3e81f11aba9212ba192c to your computer and use it in GitHub Desktop.
Save silentworks/7ecc31a9e1ea3e81f11aba9212ba192c to your computer and use it in GitHub Desktop.
Svelte component
<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>
{
"name": "world"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment