mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
850 B
49 lines
850 B
6 years ago
|
<script>
|
||
6 years ago
|
import { fade } from 'svelte/transition';
|
||
6 years ago
|
import { elasticOut } from 'svelte/easing';
|
||
6 years ago
|
|
||
6 years ago
|
let visible = true;
|
||
6 years ago
|
|
||
6 years ago
|
function spin(node, { duration }) {
|
||
6 years ago
|
return {
|
||
6 years ago
|
duration,
|
||
6 years ago
|
css: t => {
|
||
6 years ago
|
const eased = elasticOut(t);
|
||
6 years ago
|
|
||
|
return `
|
||
|
transform: scale(${eased}) rotate(${eased * 1080}deg);
|
||
|
color: hsl(
|
||
|
${~~(t * 360)},
|
||
|
${Math.min(100, 1000 - 1000 * t)}%,
|
||
|
${Math.min(50, 500 - 500 * t)}%
|
||
|
);`
|
||
|
}
|
||
|
};
|
||
6 years ago
|
}
|
||
6 years ago
|
</script>
|
||
|
|
||
|
<style>
|
||
|
.centered {
|
||
|
position: absolute;
|
||
|
left: 50%;
|
||
|
top: 50%;
|
||
|
transform: translate(-50%,-50%);
|
||
|
}
|
||
|
|
||
|
span {
|
||
|
position: absolute;
|
||
|
transform: translate(-50%,-50%);
|
||
|
font-size: 4em;
|
||
|
}
|
||
|
</style>
|
||
6 years ago
|
|
||
|
<label>
|
||
|
<input type="checkbox" bind:checked={visible}>
|
||
|
visible
|
||
|
</label>
|
||
|
|
||
|
{#if visible}
|
||
|
<div class="centered" in:spin="{{duration: 8000}}" out:fade>
|
||
|
<span>transitions!</span>
|
||
|
</div>
|
||
|
{/if}
|