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.
46 lines
642 B
46 lines
642 B
6 years ago
|
<script>
|
||
|
export let visible;
|
||
|
|
||
|
let foo_text;
|
||
|
let bar_text;
|
||
|
|
||
|
function foo(node, params) {
|
||
|
foo_text = node.textContent;
|
||
|
|
||
|
return () => {
|
||
|
if (bar_text !== `b`) {
|
||
|
throw new Error(`foo ran prematurely`);
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
duration: 100,
|
||
|
tick: t => {
|
||
|
node.foo = t;
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function bar(node, params) {
|
||
|
bar_text = node.textContent;
|
||
|
|
||
|
return () => {
|
||
|
if (foo_text !== `a`) {
|
||
|
throw new Error(`bar ran prematurely`);
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
duration: 100,
|
||
|
tick: t => {
|
||
|
node.foo = t;
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
{#if visible}
|
||
|
<div class="foo" in:foo>a</div>
|
||
|
{:else}
|
||
|
<div out:bar>b</div>
|
||
|
{/if}
|