mirror of https://github.com/sveltejs/svelte
call deferred transition function at correct time - fixes #2159
parent
474bde15e0
commit
3775f5d6ed
@ -0,0 +1,13 @@
|
|||||||
|
export default {
|
||||||
|
test({ assert, component, target, raf }) {
|
||||||
|
component.visible = true;
|
||||||
|
|
||||||
|
return Promise.resolve().then(() => {
|
||||||
|
const div = target.querySelector('.foo');
|
||||||
|
assert.equal(div.foo, 0);
|
||||||
|
|
||||||
|
raf.tick(50);
|
||||||
|
assert.equal(div.foo, 0.5);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,46 @@
|
|||||||
|
<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}
|
Loading…
Reference in new issue